1

I create new Rails application with --api parameter, like on manual http://edgeguides.rubyonrails.org/api_app.html

rails new app2 --api

For scaffold I use

bin/rails generate scaffold People first_name:string last_name:string age:integer

And Rails generate controller with not only actions for json result, and don't need "new" and "edit" actions, and html rendering
Also it generates

  create      app/views/people
  create      app/views/people/index.html.erb
  create      app/views/people/edit.html.erb
  create      app/views/people/show.html.erb
  create      app/views/people/new.html.erb
  create      app/views/people/_form.html.erb

that I don't need, because I need only API
Why?
I want to receive result, like I use rails-api gem
Version of Rails is 4.2.5

2 Answers 2

1

If you just want to generate model and controller, you can use:

bin/rails generate resource People first_name:string last_name:string age:integer
Sign up to request clarification or add additional context in comments.

1 Comment

I need scaffold like in "rails-api" gem, with CRUD actions but only for REST API on json. Without html templates and html actions
1

I found answer. "--api" command is only for 5.0 Rails

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.