[Rails] Re: Re: acl_system help is needed

Josh Kieschnick
Mon, 17 Jul 2006 21:58:12 -0000

i was finally able to get this plugin to work the way i wanted it to
work.

i ended up having to take out the before_filter line because
access_control was being processed before it.

to make sure that i don''t get nil errors from current_user, i used
something like this:

  def current_user
    User.find_by_id(session[:user_id]) || User.new
  end

i made the default role !guest, so my access_control call looks
something like this:

  access_control :DEFAULT => ''!guest'',
                 :test_csr => ''csr''

i still want to check every page to see if the user is logged in though,
so i wrote that in my permission_denied method:

  protected
  def permission_denied
    unless User.find_by_id(session[:user_id])
      session[:original_uri] = request.request_uri
      flash[:notice] = ''Please log in''
      return redirect_to :controller => ''login''
    end

    return redirect_to :controller => ''login'', :action
=> ''denied''
  end

so everything works the way i need it to but i was never able to get
everything working the way it shows in the example. the only way it
works is if the user is already logged in and tries to go to one pages
he or she does not have access to.

i would like to get any input from anyone who has had the same problems
or maybe could point out what i got wrong in the first place.

thanks