在部分地区无法通过当地人
我有一个名为 _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 } %>
当我尝试这样做时,我收到以下错误:
undefined local variable or method `entity_id' for #<ActionView::Base:0x2736bb0>
当我取出它时,我还收到一条错误,告诉我它找不到局部变量“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 #<ActionView::Base:0x2736bb0>
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)
尝试使用 :id=>@entity_id (注意名称前面的 @ 符号)。同样,@title,而不是“标题”。
Try using :id=>@entity_id (note the @ symbol preceding the name). Likewise, @title, instead of "title".