开发者

Rails: access resource model from ApplicationController

So, I've the following method in the ApplicationController, which is need to be accessed by all controllers:

  def alter_some_attribute
    @recurso = resource.find(params[:id])

    ...
  end

This method only alters a common attribute that all models have. I've tested and the contro开发者_StackOverflow社区llers access pretty good to the method. The question is how do I get the models name of the resource who access the method?

I've tried resource, resource_model, resource[:model] and all of them return the error: undefined method 'resource' for #<SomeController:0xb64a1418>


If if rightly understand you, you can try:

resourse.class
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜