Post

hoge_path とヘルパーを使用したいが、アクションの部分がわからない

事象

ヘルパーのアクション部分(?)が不明

[1] pry(main)> show-routes Prefix Verb URI Pattern GET /users/new/:encrypted_id(.:format) users#new

解決

as: :~ を付与する。

get '/users/:encrypted_id', controller: :users, action: :new, as: :users_new_encrypted_id
get '/users/:encrypted_id', controller: :users, action: :new

show-routes

users_new_encrypted_id GET /users/new/:encrypted_id(.:format) users#new

Rails のルーティング - Rails ガイド

This post is licensed under CC BY 4.0 by the author.