LoginSignup
7
9

More than 3 years have passed since last update.

No route matches {:action=>"show", :controller=>"books"}, missing required keys: [:id]

Posted at

本当初歩的なエラーで、少し考えたらすぐわかるようなところで、悔しい気持ちをもちつつ、
記録します。

表題エラー表記通り、redirect先で必要なidがなかったのが原因でした。

前:
def create
book = Book.new(book_params)
book.save
redirect_to user_path
end

修正後:
def create
book = Book.new(book_params)
book.save
redirect_to user_path(id: current_user)#修正箇所
end

7
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
9