LoginSignup
16
18

More than 5 years have passed since last update.

Rails 5.0 でのrails new後のディレクトリやGemfileを見比べる

Last updated at Posted at 2016-07-05

標準のモードとAPIモードでどう違うのかをざっと見てみたかったので実行結果をだらーっと出し、感想を述べる。

参考:
Rails 5.0: Action Cable, API mode, and so much more
Ruby on Rails 5のAPIモードと非APIモードのファイル差分

rbenv経由の Ruby 2.3.1 にて確認した。
rails new (--api)した直後のプロジェクトのディレクトリ構成とGemfileの中身を見る。
ファイル一覧は tree -a --charset=ascii を使った。

標準モード

.
|-- .gitignore
|-- Gemfile
|-- Gemfile.lock
|-- README.md
|-- Rakefile
|-- app
|   |-- assets
|   |   |-- config
|   |   |   `-- manifest.js
|   |   |-- images
|   |   |   `-- .keep
|   |   |-- javascripts
|   |   |   |-- application.js
|   |   |   |-- cable.js
|   |   |   `-- channels
|   |   |       `-- .keep
|   |   `-- stylesheets
|   |       `-- application.css
|   |-- channels
|   |   `-- application_cable
|   |       |-- channel.rb
|   |       `-- connection.rb
|   |-- controllers
|   |   |-- application_controller.rb
|   |   `-- concerns
|   |       `-- .keep
|   |-- helpers
|   |   `-- application_helper.rb
|   |-- jobs
|   |   `-- application_job.rb
|   |-- mailers
|   |   `-- application_mailer.rb
|   |-- models
|   |   |-- application_record.rb
|   |   `-- concerns
|   |       `-- .keep
|   `-- views
|       `-- layouts
|           |-- application.html.erb
|           |-- mailer.html.erb
|           `-- mailer.text.erb
|-- bin
|   |-- bundle
|   |-- rails
|   |-- rake
|   |-- setup
|   |-- spring
|   `-- update
|-- config
|   |-- application.rb
|   |-- boot.rb
|   |-- cable.yml
|   |-- database.yml
|   |-- environment.rb
|   |-- environments
|   |   |-- development.rb
|   |   |-- production.rb
|   |   `-- test.rb
|   |-- initializers
|   |   |-- application_controller_renderer.rb
|   |   |-- assets.rb
|   |   |-- backtrace_silencers.rb
|   |   |-- cookies_serializer.rb
|   |   |-- filter_parameter_logging.rb
|   |   |-- inflections.rb
|   |   |-- mime_types.rb
|   |   |-- new_framework_defaults.rb
|   |   |-- session_store.rb
|   |   `-- wrap_parameters.rb
|   |-- locales
|   |   `-- en.yml
|   |-- puma.rb
|   |-- routes.rb
|   |-- secrets.yml
|   `-- spring.rb
|-- config.ru
|-- db
|   `-- seeds.rb
|-- lib
|   |-- assets
|   |   `-- .keep
|   `-- tasks
|       `-- .keep
|-- log
|   `-- .keep
|-- public
|   |-- 404.html
|   |-- 422.html
|   |-- 500.html
|   |-- apple-touch-icon-precomposed.png
|   |-- apple-touch-icon.png
|   |-- favicon.ico
|   `-- robots.txt
|-- test
|   |-- controllers
|   |   `-- .keep
|   |-- fixtures
|   |   |-- .keep
|   |   `-- files
|   |       `-- .keep
|   |-- helpers
|   |   `-- .keep
|   |-- integration
|   |   `-- .keep
|   |-- mailers
|   |   `-- .keep
|   |-- models
|   |   `-- .keep
|   `-- test_helper.rb
|-- tmp
|   |-- .keep
|   `-- cache
|       `-- assets
`-- vendor
    `-- assets
        |-- javascripts
        |   `-- .keep
        `-- stylesheets
            `-- .keep

44 directories, 75 files
source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

APIモード

.
|-- .gitignore
|-- Gemfile
|-- Gemfile.lock
|-- README.md
|-- Rakefile
|-- app
|   |-- channels
|   |   `-- application_cable
|   |       |-- channel.rb
|   |       `-- connection.rb
|   |-- controllers
|   |   |-- application_controller.rb
|   |   `-- concerns
|   |       `-- .keep
|   |-- jobs
|   |   `-- application_job.rb
|   |-- mailers
|   |   `-- application_mailer.rb
|   |-- models
|   |   |-- application_record.rb
|   |   `-- concerns
|   |       `-- .keep
|   `-- views
|       `-- layouts
|           |-- mailer.html.erb
|           `-- mailer.text.erb
|-- bin
|   |-- bundle
|   |-- rails
|   |-- rake
|   |-- setup
|   |-- spring
|   `-- update
|-- config
|   |-- application.rb
|   |-- boot.rb
|   |-- cable.yml
|   |-- database.yml
|   |-- environment.rb
|   |-- environments
|   |   |-- development.rb
|   |   |-- production.rb
|   |   `-- test.rb
|   |-- initializers
|   |   |-- application_controller_renderer.rb
|   |   |-- backtrace_silencers.rb
|   |   |-- cors.rb
|   |   |-- filter_parameter_logging.rb
|   |   |-- inflections.rb
|   |   |-- mime_types.rb
|   |   |-- new_framework_defaults.rb
|   |   `-- wrap_parameters.rb
|   |-- locales
|   |   `-- en.yml
|   |-- puma.rb
|   |-- routes.rb
|   |-- secrets.yml
|   `-- spring.rb
|-- config.ru
|-- db
|   `-- seeds.rb
|-- lib
|   `-- tasks
|       `-- .keep
|-- log
|   `-- .keep
|-- public
|   `-- robots.txt
|-- test
|   |-- controllers
|   |   `-- .keep
|   |-- fixtures
|   |   |-- .keep
|   |   `-- files
|   |       `-- .keep
|   |-- integration
|   |   `-- .keep
|   |-- mailers
|   |   `-- .keep
|   |-- models
|   |   `-- .keep
|   `-- test_helper.rb
|-- tmp
|   |-- .keep
|   `-- cache
`-- vendor

31 directories, 55 files
source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem 'rack-cors'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

(参考) 4.2.6

.
|-- .gitignore
|-- Gemfile
|-- Gemfile.lock
|-- README.rdoc
|-- Rakefile
|-- app
|   |-- assets
|   |   |-- images
|   |   |   `-- .keep
|   |   |-- javascripts
|   |   |   `-- application.js
|   |   `-- stylesheets
|   |       `-- application.css
|   |-- controllers
|   |   |-- application_controller.rb
|   |   `-- concerns
|   |       `-- .keep
|   |-- helpers
|   |   `-- application_helper.rb
|   |-- mailers
|   |   `-- .keep
|   |-- models
|   |   |-- .keep
|   |   `-- concerns
|   |       `-- .keep
|   `-- views
|       `-- layouts
|           `-- application.html.erb
|-- bin
|   |-- bundle
|   |-- rails
|   |-- rake
|   |-- setup
|   `-- spring
|-- config
|   |-- application.rb
|   |-- boot.rb
|   |-- database.yml
|   |-- environment.rb
|   |-- environments
|   |   |-- development.rb
|   |   |-- production.rb
|   |   `-- test.rb
|   |-- initializers
|   |   |-- assets.rb
|   |   |-- backtrace_silencers.rb
|   |   |-- cookies_serializer.rb
|   |   |-- filter_parameter_logging.rb
|   |   |-- inflections.rb
|   |   |-- mime_types.rb
|   |   |-- session_store.rb
|   |   `-- wrap_parameters.rb
|   |-- locales
|   |   `-- en.yml
|   |-- routes.rb
|   `-- secrets.yml
|-- config.ru
|-- db
|   `-- seeds.rb
|-- lib
|   |-- assets
|   |   `-- .keep
|   `-- tasks
|       `-- .keep
|-- log
|   `-- .keep
|-- public
|   |-- 404.html
|   |-- 422.html
|   |-- 500.html
|   |-- favicon.ico
|   `-- robots.txt
|-- test
|   |-- controllers
|   |   `-- .keep
|   |-- fixtures
|   |   `-- .keep
|   |-- helpers
|   |   `-- .keep
|   |-- integration
|   |   `-- .keep
|   |-- mailers
|   |   `-- .keep
|   |-- models
|   |   `-- .keep
|   `-- test_helper.rb
|-- tmp
|   `-- cache
|       `-- assets
`-- vendor
    `-- assets
        |-- javascripts
        |   `-- .keep
        `-- stylesheets
            `-- .keep

38 directories, 57 files
source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

パット見の印象

挙動の差はRails公式ドキュメント等を見りゃわかるのであくまで感想を述べる。

  • 開発サーバはWebrickではなくpumaを使うらしい
  • APIモードではHTMLレンダリングに関わるものがない (当たり前だ)

無意味に感動した点は、次のいつも見るメッセージがインストール後になくなったことであった。

Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
         run  bundle exec spring binstub --all

Rails 5.0ではRuby 2.2.2以降しかサポートしないからこれも当たり前だ。

起動してみた

$ bin/rails server
=> Booting Puma
=> Rails 5.0.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.4.0 (ruby 2.3.1-p112), codename: Owl Bowl Brawl
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
Started GET "/" for ::1 at 2016-07-05 13:42:04 +0900
Processing by Rails::WelcomeController#index as HTML
  Parameters: {"internal"=>true}
  Rendering /Users/dmiyakawa/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/templates/rails/welcome/index.html.erb
  Rendered /Users/dmiyakawa/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/templates/rails/welcome/index.html.erb (5.1ms)
Completed 200 OK in 29ms (Views: 12.2ms | ActiveRecord: 0.0ms)

スクリーンショット 2016-07-05 13.42.13.png

何か微妙にイラッと来たのはなぜだろう。

なお、APIモードでもこの画面は出てくる。

16
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
18