1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add config.api_only = true to config/application.rb when using rails new --api

This commit is contained in:
Santiago Pastorino 2015-04-20 12:35:08 -04:00
parent 98a9936228
commit e9e94c1d15
2 changed files with 11 additions and 0 deletions

View file

@ -32,5 +32,12 @@ module <%= app_const_base %>
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de # config.i18n.default_locale = :de
<%- if options[:api] -%>
# Only loads a smaller set of middleware suitable for API only apps.
# Middleware like session, flash, cookies can be added back manually.
# Skip views, helpers and assets when generating a new resource.
config.api_only = true
<%- end -%>
end end
end end

View file

@ -39,6 +39,10 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase
assert_no_match(/gem 'sass-rails'/, content) assert_no_match(/gem 'sass-rails'/, content)
end end
assert_file "config/application.rb" do |content|
assert_match(/config.api_only = true/, content)
end
assert_file "config/initializers/wrap_parameters.rb" do |content| assert_file "config/initializers/wrap_parameters.rb" do |content|
assert_no_match(/wrap_parameters/, content) assert_no_match(/wrap_parameters/, content)
end end