ユーザー1人に対して一つの記事(プロフィール的なモノ)を持つwebサービスを作っています。
デバイス機能を実装しおえて、ログイン後にユーザー自身のプロフィールページに飛ぶようにしたいのですがうまくできません。
プロフィールページ記事にuser_idカラムをもたせ、記事作成時にuser_idが付けられているのを確認しました。
applicationコントローラーから
def after_sign_in_path_for(resource)
m_show_article_path[:user_id]
end
と、user_idをもったm_show(user_idユーザー専用に作ったshowアクション)に飛んでほしいのですが上手くいきません。
エラーで
ActionController::UrlGenerationError in Devise::SessionsController#create
No route matches {:action=>"m_show", :controller=>"articles"} missing required keys: [:id]
となります。 m_show_article_path[:user_id] でuser_idが拾えていない(?)のか、 こういった場合のコードの書き方がわかりません。
どなたかご教授していただけないでしょうか。
ルート追記しました。よろしくお願いします。
m_show_article GET /articles/:id/m_show(.:format) articles#m_show
articles GET /articles(.:format) articles#index
POST /articles(.:format) articles#create
new_article GET /articles/new(.:format) articles#new
edit_article GET /articles/:id/edit(.:format) articles#edit
article GET /articles/:id(.:format) articles#show
PATCH /articles/:id(.:format) articles#update
PUT /articles/:id(.:format) articles#update
DELETE /articles/:id(.:format) articles#destroy
回答1件
あなたの回答
tips
プレビュー