嗨我想弄清楚为什么我不能让我的路线正常工作我有一套路由嵌套在一个路由。当我把它连接起来,或者我应该说尝试我没有能够正确地链接它。这是在我的数据库。Rails 5路由问题
resources :posts, only: [] do
resources :comments, only: [:create, :destroy]
post '/up-vote' => 'votes#up-vote', as: :up_vote
post '/down-vote' => 'votes#down-vote', as: :down_vote
end
这就是我运行耙路线时所得到的结果| grep在我的bash上投票。
post_up_vote POST /posts/:post_id/up-vote(.:format) votes#up-vote
post_down_vote POST /posts/:post_id/down-vote(.:format) votes#down-vote
当我使用TDD时出现的错误是这个错误。
ActionController::UrlGenerationError:
No route matches {:action=>"down_vote", :controller=>"votes", :post_id=>1}
如果有人能帮我澄清这一点,我将不胜感激。谢谢。
这是一个实例的完整错误。
1) VotesController guest POST up_vote redirects the user to the sign in view
Failure/Error: post :up_vote, params: { post_id: user_post.id }
ActionController::UrlGenerationError:
No route matches {:action=>"up_vote", :controller=>"votes", :post_id=>1}
# /home/bjm8498/.rvm/gems/[email protected]/gems/rails-controller-testing-1.0.2/lib/rails/controller/testing/template_assertions.rb:61:in `process'
# /home/bjm8498/.rvm/gems/[email protected]/gems/rails-controller-testing-1.0.2/lib/rails/controller/testing/integration.rb:12:in `block (2 levels) in <module:Integration>'
# ./spec/controllers/votes_controller_spec.rb:15:in `block (4 levels) in <top (required)>'
具体是什么问题? –
我将添加一个编辑,以便我可以显示我遇到的问题。 –