简体   繁体   中英

rails-api is installing rails

I am building an Rails API-only application.

When I run from the command line this:

rails-api new myapp -T -d postgresql

I see this in the Gemfile:

source 'https://rubygems.org'

gem 'rails', '4.2.0'
gem 'rails-api'
gem 'spring', :group => :development
gem 'pg'

Rails 4.2 in installed on the system, but is it possible to install rails-api without automatically installing rails?

Partially you a right, rails-api has dependency to railties (not rails , my mistake), but railties is a core of rails .

So, you really can remove line gem 'rails', '4.2.0' from Gemfile and run server (because it part of railties ).

I think rails gem here because railties has generator of Rails applications and rails-api used it. But generated application by default has dependencies to such components of Rails as active_record , active_mailer , etc. So, rails-api just leave dependency to rails because otherwise it must remove all these dependencies from generated application.

Install Rails 5 in your system using below command:

gem install rails -v 5

then create new rails API project below command:

rails new project_name --api -d postgresql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM