开发者

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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜