Skip to content

Commit

Permalink
single quotes for controller generated routes
Browse files Browse the repository at this point in the history
Write routes in route.rb with single quotes

    get 'welcome/index'

instead of

    get "welcome/index"
  • Loading branch information
mess110 committed Jan 14, 2014
1 parent f1764a2 commit 9cdc7c0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
10 changes: 5 additions & 5 deletions guides/source/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ Rails will create several files and a route for you.

```bash
create app/controllers/welcome_controller.rb
route get "welcome/index"
route get 'welcome/index'
invoke erb
create app/views/welcome
create app/views/welcome/index.html.erb
Expand Down Expand Up @@ -272,13 +272,13 @@ Open the file `config/routes.rb` in your editor.

```ruby
Rails.application.routes.draw do
get "welcome/index"
get 'welcome/index'

# The priority is based upon order of creation:
# first created -> highest priority.
#
# You can have the root of your site routed with "root"
# root "welcome#index"
# root 'welcome#index'
#
# ...
```
Expand All @@ -295,7 +295,7 @@ root 'welcome#index'
```

`root 'welcome#index'` tells Rails to map requests to the root of the
application to the welcome controller's index action and `get "welcome/index"`
application to the welcome controller's index action and `get 'welcome/index'`
tells Rails to map requests to <http://localhost:3000/welcome/index> to the
welcome controller's index action. This was created earlier when you ran the
controller generator (`rails generate controller welcome index`).
Expand Down Expand Up @@ -328,7 +328,7 @@ Blog::Application.routes.draw do

resources :posts

root "welcome#index"
root 'welcome#index'
end
```

Expand Down
4 changes: 4 additions & 0 deletions railties/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Write controller generated routes in routes.rb with single quotes.

*Cristian Mircea Messel*

* Only lookup `config.log_level` for stdlib `::Logger` instances.
Assign it as is for third party loggers like `Log4r::Logger`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def add_routes
# Will generate -
# namespace :foo do
# namespace :bar do
# get "baz/index"
# get 'baz/index'
# end
# end
def generate_routing_code(action)
Expand All @@ -36,8 +36,8 @@ def generate_routing_code(action)
end.join

# Create route
# get "baz/index"
route = indent(%{get "#{file_name}/#{action}"\n}, depth * 2)
# get 'baz/index'
route = indent(%{get '#{file_name}/#{action}'\n}, depth * 2)

# Create `end` ladder
# end
Expand Down
4 changes: 2 additions & 2 deletions railties/test/generators/controller_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_invokes_default_template_engine

def test_add_routes
run_generator
assert_file "config/routes.rb", /get "account\/foo"/, /get "account\/bar"/
assert_file "config/routes.rb", /get 'account\/foo'/, /get 'account\/bar'/
end

def test_invokes_default_template_engine_even_with_no_action
Expand All @@ -91,6 +91,6 @@ def test_actions_are_turned_into_methods

def test_namespaced_routes_are_created_in_routes
run_generator ["admin/dashboard", "index"]
assert_file "config/routes.rb", /namespace :admin do\n\s+get "dashboard\/index"\n/
assert_file "config/routes.rb", /namespace :admin do\n\s+get 'dashboard\/index'\n/
end
end
2 changes: 1 addition & 1 deletion railties/test/generators/namespaced_generators_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_invokes_default_template_engine

def test_routes_should_not_be_namespaced
run_generator
assert_file "config/routes.rb", /get "account\/foo"/, /get "account\/bar"/
assert_file "config/routes.rb", /get 'account\/foo'/, /get 'account\/bar'/
end

def test_invokes_default_template_engine_even_with_no_action
Expand Down

0 comments on commit 9cdc7c0

Please sign in to comment.