LoginSignup
1
0

More than 5 years have passed since last update.

rails

Posted at

コントローラー名は複数のデータ(コントローラー)を作るので
ファイル名は複数形にする。

ルーティング内に
resources コントローラー名 と記入すると7つのアクションの全てを利用できるようになる。

Rails.application.routes.draw do
  devise_for :users

  root 'tweets#index'
 ⑴ resources :tweets   #tweets_controllerのresourcesメソッド(7つのアクション)
 ⑵ resources :users, only: [:show] #users_controllerのresourcesメソッド
                                                                         showアクションのみ定義している

end

tweetsコントローラは7つのアクション全て定義されるが
usersコントローラはshowアクションしか使っていないので、onlyオプションでアクションの指定をしましょう。

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