Skip to content

Commit

Permalink
Update documentation to use Rails.application instead
Browse files Browse the repository at this point in the history
References to ``AppName::Application` removed in favour of ``Rails.application``
as generated with a new rails 4.1 app.

Refs #15914

[ci skip]
  • Loading branch information
Marcel Morgan authored and robin850 committed Jun 28, 2014
1 parent c8b8443 commit 64a2cbf
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 25 deletions.
Expand Up @@ -29,7 +29,7 @@ module Session
#
# Configure your session store in config/initializers/session_store.rb:
#
# Myapp::Application.config.session_store :cookie_store, key: '_your_app_session'
# Rails.application.config.session_store :cookie_store, key: '_your_app_session'
#
# Configure your secret key in config/secrets.yml:
#
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/routing.rb
Expand Up @@ -12,7 +12,7 @@ module ActionDispatch
# Think of creating routes as drawing a map for your requests. The map tells
# them where to go based on some predefined pattern:
#
# AppName::Application.routes.draw do
# Rails.application.routes.draw do
# Pattern 1 tells some request to go to one place
# Pattern 2 tell them to go to another
# ...
Expand Down
2 changes: 1 addition & 1 deletion actionview/lib/action_view/helpers/atom_feed_helper.rb
Expand Up @@ -10,7 +10,7 @@ module AtomFeedHelper
# Full usage example:
#
# config/routes.rb:
# Basecamp::Application.routes.draw do
# Rails.application.routes.draw do
# resources :posts
# root to: "posts#index"
# end
Expand Down
2 changes: 1 addition & 1 deletion guides/code/getting_started/Rakefile
Expand Up @@ -3,4 +3,4 @@

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

Blog::Application.load_tasks
Rails.application.load_tasks
2 changes: 1 addition & 1 deletion guides/code/getting_started/config.ru
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run Blog::Application
run Rails.application
2 changes: 1 addition & 1 deletion guides/code/getting_started/config/environment.rb
Expand Up @@ -2,4 +2,4 @@
require File.expand_path('../application', __FILE__)

# Initialize the Rails application.
Blog::Application.initialize!
Rails.application.initialize!
@@ -1,4 +1,4 @@
Blog::Application.configure do
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# In the development environment your application's code is reloaded on
Expand Down
@@ -1,4 +1,4 @@
Blog::Application.configure do
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# Code is not reloaded between requests.
Expand Down
2 changes: 1 addition & 1 deletion guides/code/getting_started/config/environments/test.rb
@@ -1,4 +1,4 @@
Blog::Application.configure do
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# The test environment is used exclusively to run your application's
Expand Down
Expand Up @@ -9,4 +9,4 @@

# Make sure your secret_key_base is kept private
# if you're sharing your code publicly.
Blog::Application.config.secret_key_base = 'e8aab50cec8a06a75694111a4cbaf6e22fc288ccbc6b268683aae7273043c69b15ca07d10c92a788dd6077a54762cbfcc55f19c3459f7531221b3169f8171a53'
Rails.application.config.secret_key_base = 'e8aab50cec8a06a75694111a4cbaf6e22fc288ccbc6b268683aae7273043c69b15ca07d10c92a788dd6077a54762cbfcc55f19c3459f7531221b3169f8171a53'
@@ -1,3 +1,3 @@
# Be sure to restart your server when you modify this file.

Blog::Application.config.session_store :cookie_store, key: '_blog_session'
Rails.application.config.session_store :cookie_store, key: '_blog_session'
2 changes: 1 addition & 1 deletion guides/code/getting_started/config/routes.rb
@@ -1,4 +1,4 @@
Blog::Application.routes.draw do
Rails.application.routes.draw do
resources :posts do
resources :comments
end
Expand Down
6 changes: 3 additions & 3 deletions guides/source/action_controller_overview.md
Expand Up @@ -364,21 +364,21 @@ If you need a different session storage mechanism, you can change it in the `con
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails g active_record:session_migration")
# YourApp::Application.config.session_store :active_record_store
# Rails.application.config.session_store :active_record_store
```

Rails sets up a session key (the name of the cookie) when signing the session data. These can also be changed in `config/initializers/session_store.rb`:

```ruby
# Be sure to restart your server when you modify this file.
YourApp::Application.config.session_store :cookie_store, key: '_your_app_session'
Rails.application.config.session_store :cookie_store, key: '_your_app_session'
```

You can also pass a `:domain` key and specify the domain name for the cookie:

```ruby
# Be sure to restart your server when you modify this file.
YourApp::Application.config.session_store :cookie_store, key: '_your_app_session', domain: ".example.com"
Rails.application.config.session_store :cookie_store, key: '_your_app_session', domain: ".example.com"
```

Rails sets up (for the CookieStore) a secret key used for signing the session data. This can be changed in `config/initializers/secret_token.rb`
Expand Down
2 changes: 1 addition & 1 deletion guides/source/getting_started.md
Expand Up @@ -344,7 +344,7 @@ resource. Here's what `config/routes.rb` should look like after the
_article resource_ is declared.

```ruby
Blog::Application.routes.draw do
Rails.application.routes.draw do

resources :articles

Expand Down
2 changes: 1 addition & 1 deletion guides/source/i18n.md
Expand Up @@ -310,7 +310,7 @@ You most probably have something like this in one of your applications:

```ruby
# config/routes.rb
Yourapp::Application.routes.draw do
Rails.application.routes.draw do
root to: "home#index"
end
```
Expand Down
2 changes: 1 addition & 1 deletion guides/source/initialization.md
Expand Up @@ -526,7 +526,7 @@ The rest of `config/application.rb` defines the configuration for the
initialized. When `config/application.rb` has finished loading Rails and defined
the application namespace, we go back to `config/environment.rb`,
where the application is initialized. For example, if the application was called
`Blog`, here we would find `Blog::Application.initialize!`, which is
`Blog`, here we would find `Rails.application.initialize!`, which is
defined in `rails/application.rb`
### `railties/lib/rails/application.rb`
Expand Down
9 changes: 4 additions & 5 deletions guides/source/rails_on_rack.md
Expand Up @@ -27,10 +27,9 @@ Rails on Rack

### Rails Application's Rack Object

`ApplicationName::Application` is the primary Rack application object of a Rails
`Rails.application` is the primary Rack application object of a Rails
application. Any Rack compliant web server should be using
`ApplicationName::Application` object to serve a Rails
application. `Rails.application` refers to the same application object.
`Rails.application` object to serve a Rails application.

### `rails server`

Expand Down Expand Up @@ -141,7 +140,7 @@ use ActionDispatch::ParamsParser
use Rack::Head
use Rack::ConditionalGet
use Rack::ETag
run MyApp::Application.routes
run Rails.application.routes
```

The default middlewares shown here (and some others) are each summarized in the [Internal Middlewares](#internal-middleware-stack) section, below.
Expand Down Expand Up @@ -201,7 +200,7 @@ use ActionDispatch::Static
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x00000001c304c8>
use Rack::Runtime
...
run Blog::Application.routes
run Rails.application.routes
```

If you want to remove session related middleware, do the following:
Expand Down
4 changes: 2 additions & 2 deletions guides/source/routing.md
Expand Up @@ -709,7 +709,7 @@ class BlacklistConstraint
end
end

TwitterClone::Application.routes.draw do
Rails.application.routes.draw do
get '*path', to: 'blacklist#index',
constraints: BlacklistConstraint.new
end
Expand All @@ -718,7 +718,7 @@ end
You can also specify constraints as a lambda:

```ruby
TwitterClone::Application.routes.draw do
Rails.application.routes.draw do
get '*path', to: 'blacklist#index',
constraints: lambda { |request| Blacklist.retrieve_ips.include?(request.remote_ip) }
end
Expand Down

0 comments on commit 64a2cbf

Please sign in to comment.