使用 onclick 切换图像

发布于 2024-10-18 17:29:56 字数 847 浏览 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 } %>

当我尝试这样做时,我收到以下错误:

#

当我取出它时,我也得到一个错误,告诉我它找不到局部变量“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 技术交流群。

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

发布评论

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

评论(1

贩梦商人 2024-10-25 17:29:56

您确定错误来自部分吗?您在 form_tag 中使用 entity_id。它是在哪里定义的?部分中未使用 title 。不过它是在 legend 内部使用的。是这样定义的吗?

Are you sure the error is coming from the partial? You are using entity_id in the form_tag. Where is it being defined? title isn't used in the partial. It is used inside of legend though. Is that defined?

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