【问题标题】:Rails 3 - how to apply link_to on image_tag with :remote => true attrubuteRails 3 - 如何使用 :remote => true 属性在 image_tag 上应用 link_to
【发布时间】:2011-08-05 08:15:34
【问题描述】:

我正在努力解决有关图像正确设置参数的问题,即链接。混凝土,

这行得通

<%= link_to (image_tag 'img name', 
            :class => 'css'),
        ({controller, action, parameter})%>

这已经不行了

<%= link_to (image_tag 'img name', 
            :class => 'css'),
        ({controller, action, parameter},
        {:remote => true})
%>

可能你会认为这是一个非常低的问题,但我试图解决它半个多小时仍然没有......所以我会感谢每一个帮助。

【问题讨论】:

  • 试试这个 link_to image_tag 'img name', :class=> 'css', {controller, action, parameter}, {:remote => true}
  • 你遇到了什么错误?
  • 语法不好,括号有问题。下面的答案解决了它。

标签: ruby-on-rails-3 image view link-to


【解决方案1】:

你可以试试这个。 (自己没有测试过)

&lt;%= link_to(image_tag('img name', :class =&gt; 'css'), url_for(:controller =&gt; 'controller_name', :action =&gt; 'action_name'), :remote =&gt; true) %&gt;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-11
    • 1970-01-01
    • 1970-01-01
    • 2011-11-02
    • 1970-01-01
    相关资源
    最近更新 更多