Sam
Sam

Reputation: 416

rails --api doesn't work

So I just installed RoR on my Ubuntu box and I'm trying to start a new API application. I have been scratching my head for the past 3, 4 hours why rails still generates the views/helpers/assets directories. I run the following command

rails new my_app --api

I'm running the following ruby and rails versions:

$ ruby -v
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
$ rails -v
Rails 4.2.6

I would really appreciate it if someone could tell me what I'm doing wrong.

Thank you!

Upvotes: 2

Views: 298

Answers (2)

Undo
Undo

Reputation: 25697

Rails' API mode was added in 5.0. To get it in Rails 4.x, you should be able to install the rails-api gem and use the rails-api new generator:

gem install rails-api
rails-api new my_app

Upvotes: 2

NM Pennypacker
NM Pennypacker

Reputation: 6952

You need to be on Rails 5.x+ to use the generator with the --api flag

Upvotes: 2

Related Questions