Re: [Rails] what's wrong?
On 12 February 2012 19:34, Mauro <mrsanna1@gmail.com> wrote:
> On 12 February 2012 12:14, Colin Law <clanlaw@googlemail.com> wrote:
>> On 11 February 2012 23:46, Mauro <mrsanna1@gmail.com> wrote:
>>> route.rb
>>>
>>> match "/:layout" => "company@index"
>>>
>>> in application_controller I have:
>>>
>>> before_filter :authenticate_user!
>>> rescue_from DeviseLdapAuthenticatable::LdapException do |exception|
>>> render :text => exception, :status => 500
>>> end
>>> protect_from_forgery
>>> before_filter :set_layout
>>>
>>> layout :specify_layout
>>>
>>> def specify_layout
>>> if @current_layout == :intra
>>> "intranet"
>>> elsif @current_layout == :inter
>>> "internet"
>>> else
>>> "application"
>>> end
>>> end
>>>
>>> def set_layout
>>> if params[:layout] == "intraOp"
>>> session[:current_layout] = :intra
>>> elsif params[:layout] == "interOp"
>>> session[:current_layout] = :inter
>>> else
>>> session[:current_layout] = nil
>>> end
>>> @current_layout = session[:current_layout]
>>> end
>>> end
>>>
>>> in another controller I have:
>>>
>>> skip_filter :authenticate_user!, :only => [:index, :show] unless
>>> @current_layout.nil?
>>>
>>> unless condition seem does not work.
>>> What I am missing?
>>
>> Is it possible that your before_filter .. unless test is being run
>> before set_layout is called? You could display some debug output to
>> find out.
>
> It seems so, I've tried before_filter :set_layout, :authenticate_user!
> but it seems that @current_layout is always nil when skip_filter is
> run, it is strange to me because set_layout is run before
> authenticate_user I think.
Well put in some debug and prove it one way or the other.
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home