LoginSignup
0
0

More than 1 year has passed since last update.

scopeとmoduleの使い分け

Posted at

はじめに

使い分けが曖昧になることが多かったので記事にまとめてみました!

scope

  • URLは指定のパスにしたい、かつファイル構成は変更したくないときに使用する
  • URIパターンのみをカスタマイズしたいときに使用する
Prefix Verb URI Pattern Controller
articles /admin/articles articles#index
new_article /admin/articles/new articles#new

URI Patternのみadminが付加されており、app/controllersディレクトリ配下のコントローラである

module

  • module(scope module)はURLのパスは変更したくない、かつファイル構成は指定したい時に使用
  • Controller#Actionのみ変更したい時に使用
Prefix Verb URI Pattern Controller
articles /articles admin/articles#index
new_article /articles/new admin/articles#new

コントローラーの前にadminが付与されている

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