Skip JSON format in rails generate scaffold Skip JSON format in rails generate scaffold ruby-on-rails ruby-on-rails

Skip JSON format in rails generate scaffold


Comment out gem jbuilder in your Gemfile and respond_to blocks won't be generated.


Just clone the file

https://github.com/rails/rails/blob/v5.2.2/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb

to your

lib/rails/generators/rails/scaffold_controller/templates/controller.rb

path in your application and customize what you want. Also, you can write your own generators for scaffolding ( http://guides.rubyonrails.org/generators.html ).


I think you'd be missing an opportunity. For one thing, you'd be teaching non-standard Rails, so your students might be confused when they see the normal version in their own installations.

More importantly, the controllers are formatted that way for a reason. Rails puts an emphasis on REST, which encourages access to resources via multiple data formats. Many modern apps are de-emphasizing slower server-rendered html/erb responses in favor of json APIs. I realize this is a little over a year after your OP, and you have limited time in class, just adding some thoughts for anyone who might happen by. I think you could wave your hand over the respond_to and tell them it's setting you up for some future possibilities.