In a Rails view how do I reference the object passed to respond_with in the controller?
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.
精彩评论