LoginSignup
1
1

More than 5 years have passed since last update.

Rails: Namespaceの時のform_forの書き方

Posted at

If you have created namespaced routes, form_for has a nifty shorthand for that too. If your application has an admin namespace then

form_for [:admin, @article]
will create a form that submits to the ArticlesController inside the admin namespace (submitting to admin_article_path(@article) in the case of an update). If you have several levels of namespacing then the syntax is similar:

form_for [:admin, :management, @article]

1
1
1

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