【问题标题】:Link not working in RoR链接在 RoR 中不起作用
【发布时间】:2014-04-12 16:17:43
【问题描述】:

我有这个链接

<li><a href="<%= destroy_user_session_path(:method => :delete) %>"><button
class="button icon-left ion-ios7-compose">Log out</button></a></li>

但它不起作用。如何修复 :method =&gt; :delete 以便它在链接中工作? 我收到此错误:

No route matches [GET] "/users/sign_out"

另外,我正在为用户使用设计。

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 methods devise


    【解决方案1】:

    使用 link_to 帮助器(也请查看您的 html,通常在链接中找不到按钮)。

    <li><%= link_to 'Log out', destroy_user_session_path, method: :delete %></li>
    

    【讨论】:

      【解决方案2】:

      你必须这样写

      <li><%= link_to "Log Out", destroy_user_session_path, :class => "button icon-left ion-ios7-compose", :method => :delete %></li>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多