0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

rails Prefixを変更する方法

Posted at

##Prefixを変更する方法
変更する方法はroutes.rbでPrefixを書き換えることです。

newアクションをもつUserコントローラーを作ったとします。

コンソールでrails routesでルーティングを調べてみると

   Prefix Verb URI Pattern          Controller#Action
users_new GET  /users/new(.:format) users#new

defaultではPrefixがusers_newとなっています。

users_new_pathではなくsignup_pathを使いたいなら

routes.rb
 get 'users/new'
 
 get 'sighup', to:'users#new'

上記のように書き換えることでsignup_pathが使えるようになります。

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?