【问题标题】:link_to does not work in production (Heroku)link_to 在生产中不起作用(Heroku)
【发布时间】:2016-04-06 23:59:12
【问题描述】:

但是,我在本地使用 link_to 没有任何问题,一旦我部署到 Heroku,我就会收到以下错误:

users#show (ArgumentError) "arguments passed to url_for can't be handled. Please require routes or provide your own implementation" 
app/views/users/show.html.erb:176:in `_app_views_users_show_html_erb__222687663100622833_69928454693640'

我正在使用 ruby​​ '2.2.0' 和 rails '4.2.0'

关于如何进一步调试或在本地复制它的任何想法?


更新 1. 这是显示分页链接的实际视图代码。生成的路由应该是 /users/1?page=1 等。

 <div class="row text-center">
   <%= will_paginate collection, renderer: BootstrapPagination::Rails %>
 </div>

【问题讨论】:

标签: ruby-on-rails heroku


【解决方案1】:

问题在于我的一个模型中包含的 url_helpers - 在我删除以下包含后一切正常。

include Rails.application.routes.url_helpers

Using the correct url_for method in a Rails engine spec

【讨论】:

    猜你喜欢
    • 2015-01-23
    • 2012-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-19
    • 1970-01-01
    • 2015-02-06
    • 2018-12-10
    相关资源
    最近更新 更多