Skip to content

Commit fd4e360

Browse files
committed
Merge pull request rails#10389 from wangjohn/removing_the_app_constant_and_replace_with_rails_application_instance
Removing the app constant and replacing it with Rails.application
2 parents 6893705 + 9703d67 commit fd4e360

File tree

13 files changed

+22
-18
lines changed

13 files changed

+22
-18
lines changed

railties/lib/rails/engine.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ module Rails
124124
#
125125
# Now you can mount your engine in application's routes just like that:
126126
#
127-
# MyRailsApp::Application.routes.draw do
127+
# Rails.application.routes.draw do
128128
# mount MyEngine::Engine => "/engine"
129129
# end
130130
#
@@ -154,7 +154,7 @@ module Rails
154154
# Note that now there can be more than one router in your application, and it's better to avoid
155155
# passing requests through many routers. Consider this situation:
156156
#
157-
# MyRailsApp::Application.routes.draw do
157+
# Rails.application.routes.draw do
158158
# mount MyEngine::Engine => "/blog"
159159
# get "/blog/omg" => "main#omg"
160160
# end
@@ -164,7 +164,7 @@ module Rails
164164
# and if there is no such route in +Engine+'s routes, it will be dispatched to <tt>main#omg</tt>.
165165
# It's much better to swap that:
166166
#
167-
# MyRailsApp::Application.routes.draw do
167+
# Rails.application.routes.draw do
168168
# get "/blog/omg" => "main#omg"
169169
# mount MyEngine::Engine => "/blog"
170170
# end
@@ -251,7 +251,7 @@ module Rails
251251
# created to allow you to do that. Consider such a scenario:
252252
#
253253
# # config/routes.rb
254-
# MyApplication::Application.routes.draw do
254+
# Rails.application.routes.draw do
255255
# mount MyEngine::Engine => "/my_engine", as: "my_engine"
256256
# get "/foo" => "foo#index"
257257
# end

railties/lib/rails/generators/actions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def add_source(source, options={})
8686
# end
8787
def environment(data=nil, options={}, &block)
8888
sentinel = /class [a-z_:]+ < Rails::Application/i
89-
env_file_sentinel = /::Application\.configure do/
89+
env_file_sentinel = /Rails\.application\.configure do/
9090
data = block.call if !data && block_given?
9191

9292
in_root do

railties/lib/rails/generators/rails/app/templates/Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
require File.expand_path('../config/application', __FILE__)
55

6-
<%= app_const %>.load_tasks
6+
Rails.application.load_tasks

railties/lib/rails/generators/rails/app/templates/config/environment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
require File.expand_path('../application', __FILE__)
33

44
# Initialize the rails application.
5-
<%= app_const %>.initialize!
5+
Rails.application.initialize!

railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%= app_const %>.configure do
1+
Rails.application.configure do
22
# Settings specified here will take precedence over those in config/application.rb.
33

44
# In the development environment your application's code is reloaded on

railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%= app_const %>.configure do
1+
Rails.application.configure do
22
# Settings specified here will take precedence over those in config/application.rb.
33

44
# Code is not reloaded between requests.

railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%= app_const %>.configure do
1+
Rails.application.configure do
22
# Settings specified here will take precedence over those in config/application.rb.
33

44
# The test environment is used exclusively to run your application's

railties/lib/rails/generators/rails/app/templates/config/initializers/secret_token.rb.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99

1010
# Make sure your secret_key_base is kept private
1111
# if you're sharing your code publicly.
12-
<%= app_const %>.config.secret_key_base = '<%= app_secret %>'
12+
Rails.application.config.secret_key_base = '<%= app_secret %>'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Be sure to restart your server when you modify this file.
22

3-
<%= app_const %>.config.session_store :cookie_store, key: <%= "'_#{app_name}_session'" %>
3+
Rails.application.config.session_store :cookie_store, key: <%= "'_#{app_name}_session'" %>

railties/lib/rails/generators/rails/app/templates/config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%= app_const %>.routes.draw do
1+
Rails.application.routes.draw do
22
# The priority is based upon order of creation: first created -> highest priority.
33
# See how all your routes lay out with "rake routes".
44

0 commit comments

Comments
 (0)