When I use rails g scaffold Model key:string value:string
command it creates both controller and views (erb, scss, js). How can I generate only controller which will respond with only JSON format.
Static Scaffolding needs user insertion commands to generate data fields, whereas Dynamic Scaffolding generates the entire content at run time.
Rails scaffolding is a quick way to generate some of the major pieces of an application. If you want to create the models, views, and controllers for a new resource in a single operation, scaffolding is the tool for the job.
Without having to modify configuration:
rails g scaffold TestLink --api
Pro tip: Use the --pretend flag to see what will be created before running:
rails g scaffold TestLink --api --pretend
If you already have a project setup as a normal rails app, you can make the generators api only by setting it up in config/application.rb
.
config.generators do |g|
g.api_only = true
end
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