Inherited views in Rails 3.1 - instance variables
How can an inherited view 开发者_如何学Ctemplate know what the (main) instance variable name is? Is there:
- some built-in way to detect them using some magic, or;
- we roll our own (with the controller name is the only method I can think of right now), or;
- use some generic name, or;
- ???
Rolling my own right now, but if the wheel's already been invented...
Ok after some reading and experimentation, I found out that it has the same helpers as inherited_resource_views
collection
to get the collection (eg. index action)resource
to get the resource (eg. show action)
And the resource(s) are still available as instance variables (eg. @user
in UsersController
)
精彩评论