Search code examples
ruby-on-railsruby-on-rails-3.2scaffolding

Is Scaffold in rails 3.2 a better option?


I am new to ruby on rails.I want to know why do we use scaffold and should we run scaffold directly after the bundle install process. I read somewhere that we have to first create controller by doing:-

rails generate controller 

and then run the scaffold. which one is the preferred method. Create the model,controller then use scaffold or run scaffold directly.


Solution

  • If you want to build something in hurry and doesn't care much about the code, then you can scaffold. Once you scaffold a resource, rails will provide you a basic/working crud operation, a restful route and all required views. You don't need to create model, controller, view and setup routes by yourself. http://guides.rubyonrails.org/getting_started.html#getting-up-and-running-quickly-with-scaffolding

    However, once you get to know the working of the rails and best practices, one generally prefer not to use the scaffold and add the required components by themselves. This will allows the developer to customize and build the app the way they preferred.