layout with symbol generates error
I have a admin namespace and Admin::UserController controller. When I try to use a layout called admin with symbol, the rails throw an exception, but if I call layout开发者_如何转开发 admin as a string, works sucessfull.
The exception message is the following:
You specified nil as the layout, but no such method was found
I just want to know why this happens...
thanks.
As per here:
http://ap.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html
Sometimes you want to alternate layouts depending on runtime information, such as whether someone is logged in or not. This can be done either by specifying a method reference as a symbol or using an inline method (as a proc).
So long story short, when you specify a symbol, Rails actually expects that to be a method reference, thus the reason why it is claiming that there was no method found.
精彩评论