Artik
Artik

Reputation: 153

Ruby On Rails --api

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

Upvotes: 1

Views: 90

Answers (2)

Artik
Artik

Reputation: 153

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

Upvotes: 1

Yang
Yang

Reputation: 1923

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

Upvotes: 1

Related Questions