Sticking to the 7 resourceful actions in a controller

In Part Two he says to stick to the seven resourceful actions when writing controllers, but then he adds in other methods. He uses the sessions_controller as an example, which has two additional methods: set_flash_message and session_params. I’m just curious what he means by sticking to the 7. And how do I know when its alright to add a method to a controller?


The 7 golden restful actions

  • Index
  • Show
  • Destroy
  • New
  • Create
  • Edit
  • Update

You should try to stick to them, because it will be easier to understand the code for others and yourself. It will make it easier to implement an API and you stick with the HTTP methods(the links below explains better)

So instead of writing display_this_tweet you should write show
When neither of the 7 actions fit your purpose make your own.

For more read and

1 Like

In addition to what @janukevic has said, the seven resourceful actions are public methods.

In the case of the sessions controller, the 2 methods that were added were private. These methods are used only inside the context of the sessions controller and not accessed from outside it like the seven resourceful actions.

Thank you for your help!