Skip JSON format in rails generate scaffold

前端 未结 4 1303
南旧
南旧 2021-02-07 01:29

When you generate a rails scaffold using a command like rails g scaffold Thing is there any way to avoid getting that annoying

respond_to do |format         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-07 02:17

    You'll notice that the JSON response is coded directly into the template for the rails generator here:

    https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb

    I think something to note is that the scaffold generator is really intended to illustrate and moreover educate on how the Rails stack works, it shows how you can edit the controller to provide many different formats to suit your needs!

提交回复
热议问题