I am using the CanCan authorization plugin (http://github.com/ryanb/cancan) for my application and it has worked great so far. I had it set like the following:
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user
if user.role == "admin"
can :manage, :all
else
can :read, :all
end
end
end
This allows me to designate some users Admins and only they can access write functions. Now I want to take it another step and make it so people who are not logged in at all (current_user/user_session does not exist) cannot access some controllers of the site. I know it should be some sort of elsif with the middle part of the code for the user and the final else for everyone else. However, I have not been able to figure out the best way to go about setting this up. Is anyone familiar with CanCan and have some ideas on how to best approach this type of situation.
Thanks guys, every bit helps me learn more about rails and development in general!