使用 onclick 切换图像
我有一个名为 _avatar.html.erb 的部分 我想传递一个 id 作为名为entity_id 的局部变量,它将是一个对象的id。
<% form_tag({:controller => "avatar", :action => "upload", :id => entity_id}, :multipart => true ) do %>
<fieldset>
<legend><%= title %></legend>
<% if avatar.exists? %>
<%= avatar_tag(avatar) %>
[<%= link_to "delete", {:controller => "avatar",:action => "delete", :id => entity_id},:confirm => "Are you sure" %>]
...
这是对 parital 的调用:
<%= render :partial => 'avatar/avatar', :locals => {:avatar => @avatar, :title => @title, :entity_id => @board.id } %>
当我尝试这样做时,我收到以下错误:
#
当我取出它时,我也得到一个错误,告诉我它找不到局部变量“title” ”。
任何人都可以帮忙这似乎是正确的方法。
提前致谢
I have a partial called _avatar.html.erb
I want to pass in an id as a local variable called entity_id which will be the id of an object.
<% form_tag({:controller => "avatar", :action => "upload", :id => entity_id}, :multipart => true ) do %>
<fieldset>
<legend><%= title %></legend>
<% if avatar.exists? %>
<%= avatar_tag(avatar) %>
[<%= link_to "delete", {:controller => "avatar",:action => "delete", :id => entity_id},:confirm => "Are you sure" %>]
...
Here is the call for the parital:
<%= render :partial => 'avatar/avatar', :locals => {:avatar => @avatar, :title => @title, :entity_id => @board.id } %>
When I try this I get the following errors:
undefined local variable or method `entity_id' for #
When I take that out I also get an error telling me it can't find the local variable "title".
Can anyone help this seems to be the correct way to do this.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定错误来自部分吗?您在
form_tag
中使用entity_id
。它是在哪里定义的?部分中未使用title
。不过它是在legend
内部使用的。是这样定义的吗?Are you sure the error is coming from the partial? You are using
entity_id
in theform_tag
. Where is it being defined?title
isn't used in the partial. It is used inside oflegend
though. Is that defined?