Let's say I have a SessionsController
, which controls user login and logout, but the only actions I really need are new (for displaying login form), create (for authentication and login) and destroy for logging out the user.
Is there any problem if I just have these three actions in my controller, or do I have to implement them all to make it correctly RESTful?
And second little question. Some people say that scaffolding is bad, and that one should write code by hand, but I find it pretty useful and time saving.
Is it OK to use scaffolding, or is it evil that should be avoided and why?
It is definitely okay to only create the RESTful actions which you want to support for that resource. You do not have to define all 7 actions. In fact, the majority of my controllers do not use all 7 actions.
Is it OK to use scaffolding, or is it evil that should be avoided and why?
The built-in Rails scaffolding is mainly designed to help get off the ground when beginning. I personally don't use it for everyday development for a few reasons.
However, I am a fan of scaffolding for speeding up development. This is why I created the nifty_scaffold generator which I use almost all the time. It does not have the problems mentioned above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With