【发布时间】:2016-02-16 05:02:54
【问题描述】:
我有以下路线:
resources :transactions do
collection do
post :detail
end
end
当我到达http://localhost:3000/transactions/detail 时,rails 给了我这个错误:
ActiveRecord::RecordNotFound in TransactionsController#show
找不到 id=detail 的交易
这让我觉得表演路线优先于我的收藏路线,但我不知道为什么。与此问题非常相似:Rails ignores collection route and goes with show action instead,但我没有重复的资源 :transactions 条目。
【问题讨论】:
-
@RahulSingh 在这里是正确的 - 如果您正在执行显示操作,那么您正在发送 GET 请求 - 而不是 POST。您不能只在地址栏中输入
http://localhos:3000/transactions/detail,使用cURL 或Postman 或更好的request spec 来测试它。
标签: ruby-on-rails ruby-on-rails-4