gnerkus
gnerkus

Reputation: 12019

Create REST API in Rails 5 with only needed functionality

When I create a new REST API using the --api command in Rails 5 beta, it installs the actioncable and sprockets gems which I do not need.

How do I create the API without these gems?

Upvotes: 0

Views: 240

Answers (1)

gnerkus
gnerkus

Reputation: 12019

The rails command provides the -S option which skips the installation of the sprockets-rails gem.

The rails command for Rails 5 provides the -C option which, when used, skips the installation of ActionCable in the new app. It does not install the redis gem required by ActionCable. Because the actioncable gem has been merged into rails, the installation creates the files required for ActionCable but then removes them:

remove config/cable.yml
remove app/assets/javascripts/cable.coffee
remove app/channels

Both the -S and -C options can be combined in one command:

$ rails new rest-api --api -C -S

Upvotes: 6

Related Questions