So I thought "Well, I'll do this in a before_filter in
application_controller.rb." Like this:
class ApplicationController < ActionController::Base
before_filter :auth, :except => [:auth]
layout 'application'
protected
def auth
if *user is signed in, however the HELL I do that*
user = User.find_by_name("guest")
sign_in(@user)
else
authenticate_user!
end
end
end
Simple enough, right?
Wrong. Too many redirects.
I am missing something very simple, like always.
I have been reading the Devise code for clues on how to use it. It's
very well-written of course and I can follow much of it. But when I
see stuff like:
included do
helper DeviseHelper
helpers = %w(resource scope_name resource_name
resource_class devise_mapping devise_controller?)
hide_action *helpers
helper_method *helpers
prepend_before_filter :is_devise_resource?
skip_before_filter *Devise.mappings.keys.map { |
m| :"authenticate_#{m}!" }
end
My mind immediately goes into shutdown mode. See those asterisks? I
don't even know what those mean, after 5 years of coding in Rails. I
don't know how to improve.
Back to my immediate question, I am trying to figure out how to
automatically log in an un-logged-in user as "Guest".