在部分地区无法通过当地人

发布于 2024-10-18 15:34:49 字数 961 浏览 1 评论 0原文

我有一个名为 _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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

四叶草在未来唯美盛开 2024-10-25 15:34:49

尝试使用 :id=>@entity_id (注意名称前面的 @ 符号)。同样,@title,而不是“标题”。

Try using :id=>@entity_id (note the @ symbol preceding the name). Likewise, @title, instead of "title".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文