开发者

In a Rails view how do I reference the object passed to respond_with in the controller?

开发者 https://www.devze.com 2023-04-05 22:57 出处:网络
Say I have the following: class ProjectsController < ApplicationController responds_to :html def show

Say I have the following:

class ProjectsController < ApplicationController
  responds_to :html

  def show
    @project = Project.find(params[:id])
    res开发者_StackOverflowpond_with(@project)
  end
end

class UsersController < ApplicationController
  responds_to :html

  def show
    @user = User.find(params[:id])
    respond_with(@user)
  end
end

Is there a method I can use to reference the object passed to respond_with in the layouts/application.html.erb template without needing to know the assigned variable's name?

Thanks.


No there is no method(at least I didn't hear about such method). But if you want you can look here, it is pretty nice solution: Decent exposure

I hope I helped you alittle.

0

精彩评论

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