首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >path助手在从Rails-2迁移到Rails-3时在控制台上生成exeception

path助手在从Rails-2迁移到Rails-3时在控制台上生成exeception
EN

Stack Overflow用户
提问于 2015-07-13 09:17:50
回答 1查看 40关注 0票数 0

我试图修改我的脚本,我正在从rails 2.3迁移到rails 3.1,但我面临着一个奇怪的问题。我看到当我使用像这样的路径助手时

在rails 3.1中,我得到了一个异常,但rails 2.3曾经工作过,我的意思是,当我传递值给路径助手( order.customer_id为0)时,它会生成一个创建新客户的路径,但是在rails 3.1中,它会生成一个异常,下面是我在rails 3.1中看到的错误描述。

helper.link_to customer_email, app.store_customer_path(store,order.customer_id),当order.customer_id为空时,我在控制台上得到一个异常,如下所示

下面是我在rails 2.3中观察到的错误

ActionController::RoutingError:{:controller=>"customers", :action=>"show", :store_id=#<object>}生成store_customer_url失败

。但是,当我加载一个网页时,我会看到我得到了一条创建新客户的路径。

这是我的相关routes.rb代码

代码语言:javascript
复制
        resources :stores do
      resources :customers do
        collection do 
          get :get_customers, :download, :csv_template
        end
        match :upload, :import, :map, :on => :collection
        member do
          get :more
        end
        resources :dropship_profiles
        resources :address
      end
end

但在rails 3.1中

在控制台上,我看到异常,当从浏览器加载时,我也看到异常

我无法理解这一点,它使我困惑,谁能帮忙,谢谢。

EN

回答 1

Stack Overflow用户

发布于 2015-07-13 11:19:20

在浏览完您的routes.rb之后,我没有看到任何相关的路径,这些路径可以路由到store_customer_path...kindly,使用当前的路径或者通过运行rake routes > path.txt创建新的one...verify,然后在path.txt中轻松地检查您的路由

=============UPDATED ANSWER==============

在这里,您传递两个值,只需传递一个

代替helper.link_to customer_email, app.store_customer_path(store,order.customer_id) 尝试

代码语言:javascript
复制
helper.link_to customer_email, app.store_customer_path(order.customer_id)

代码语言:javascript
复制
helper.link_to customer_email, app.store_customer_path(store.id)

正如您的path所说的/stores/:store_id/customers/new(.:format),您只需要通过store_id才能使其工作。

要了解从Rails 2到Rails 3路由的主要更改,...you必须查看这个页面

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31379549

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档