A neat way to write routing: relaxed:
background When specifying the routing, if you use 6 out of 7 actions, if you write it as only, it will be messy and long, and I personally became crap: weary: so I will leave it as a memorandum: bow_tone1:
First, let's review the seven Rails actions: writing_hand:
Action | role |
---|---|
index | Display a list |
new | to add |
create | Register additional content |
edit | To edit |
update | Update your edits |
destroy | delete |
show | Display individual contents |
: warning: Here we route to a resource called "tweets"
routes.rb
resources :tweets
: warning: Here, "index", "new", and "create" are used.
routes.rb
resources :tweets, only: [:index, :new, :create]
: warning: Here, we will use an action other than "show".
routes.rb
resources :tweets, except: [:show]
It's easy to fill in ** only **, but using ** except ** makes the code cleaner and easier to read: point_up: I will also keep in mind: sparkles: laughing:
https://web-camp.io/magazine/archives/16815
Recommended Posts