This project is archived and is in readonly mode.
Named Routes in routes.rb shows syntax error in actionpack
Reported by lakshmanan | March 4th, 2011 @ 07:11 AM | in 3.x
I have a named route in my routes.rb file like
match "/orders/summary_sales/:event_id.:format" => "orders#summary_sales", :as => "formatted_summary_sales"
If i leave a space after "formatted_summary_sales" in :as option like below
match "/orders/summary_sales/:event_id.:format" => "orders#summary_sales", :as => "formatted_summary_sales "
and if i run "rake routes", the following error occurs.
Invoke routes (first_time) Invoke environment
(first_time) ** Execute environment rake aborted!
/Users/lakshmanan/.rvm/gems/ruby-1.9.2-p136@da3/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:161:
syntax error, unexpected '(', expecting ';' or '\n'
...r_formatted_summary_sales url(options = nil) ... ... ^
/Users/lakshmanan/.rvm/gems/ruby-1.9.2-p136@da3/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:161:
syntax error, unexpected ')', expecting $end ...mmary_sales
url(options = nil) ... ... ^
/Users/lakshmanan/.rvm/gems/ruby-1.9.2-p136@da3/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:160:in
module_eval'
/Users/lakshmanan/.rvm/gems/ruby-1.9.2-p136@da3/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:160:in
define_hash_access'
/Users/lakshmanan/.rvm/gems/ruby-1.9.2-p136@da3/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:151:in
block in define_named_route_methods'
/Users/lakshmanan/.rvm/gems/ruby-1.9.2-p136@da3/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:149:in
each'
/Users/lakshmanan/.rvm/gems/ruby-1.9.2-p136@da3/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:149:in
define_named_route_methods'
/Users/lakshmanan/.rvm/gems/ruby-1.9.2-p136@da3/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:100:in
add'
/Users/lakshmanan/.rvm/gems/ruby-1.9.2-p136@da3/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:300:in
add_route'
/Users/lakshmanan/.rvm/gems/ruby-1.9.2-p136@da3/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:273:in
match'
/Users/lakshmanan/.rvm/gems/ruby-1.9.2-p136@da3/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:1173:in
match'
/Users/lakshmanan/.rvm/gems/ruby-1.9.2-p136@da3/gems/actionpack-3.0.5/lib/action_dispatch/routing/mapper.rb:1358:in
match'
/Users/lakshmanan/projects/da/config/routes.rb:92:in `block in
'
Strange. But if I i dont give that space, I get the proper rake routes ouput.
Comments and changes to this ticket
-
lakshmanan March 4th, 2011 @ 08:00 AM
It actually shows a syntax error. The title of this ticket should have been like "Named Routes in routes.rb shows syntax error actionpack"
-
Aditya Sanghi March 4th, 2011 @ 09:59 AM
- Title changed from Named Routes in routes.rb shows syntax actionpack to Named Routes in routes.rb shows syntax error in actionpack
- Importance changed from to Low
-
Andrew White March 4th, 2011 @ 11:03 AM
- State changed from new to open
- Milestone set to 3.x
- Assigned user changed from Santiago Pastorino to Andrew White
What's happening is the :as option is used as the named route helper method name. The fix is to raise an ArgumentError when the route is being defined if the :as option is not a valid method name. I'll fix this over the weekend.
-
Diego Carrion March 6th, 2011 @ 05:10 AM
I attached a patch in case the expected behavior is not to break.
-
Andrew White March 6th, 2011 @ 05:17 AM
Thanks, Diego but I think it's better to raise an exception - the name may be invalid for other reasons such as a leading number, space in the middle, etc.
-
lakshmanan March 6th, 2011 @ 06:03 AM
@Diego +1
I think, at least we must :strip the name before considering. Deigo's patch does exactly that.
-
Andrew White March 6th, 2011 @ 06:16 AM
But if you just strip the name your routes.rb file is left with an invalid argument - something I'd prefer to know.
-
Repository March 6th, 2011 @ 07:26 AM
- State changed from open to resolved
(from [2437c78f40d5e89aa3dc1c960bbe12fe0427b627]) Raise ArgumentError if route name is invalid [#6517 state:resolved] https://github.com/rails/rails/commit/2437c78f40d5e89aa3dc1c960bbe1...
-
Repository March 6th, 2011 @ 07:26 AM
(from [e00867bc437b6a681491ef59e13423051e6d98f0]) Raise ArgumentError if route name is invalid [#6517 state:resolved] https://github.com/rails/rails/commit/e00867bc437b6a681491ef59e1342...
-
Repository March 7th, 2011 @ 04:51 PM
(from [9cee693213e0205cb5992728bb516215e34cb79f]) Merge branch 'master' of github.com:rails/rails
- 'master' of github.com:rails/rails: (44 commits) Fixed indentation in actionmailer base_test [#6538 state:committed] remove unused assigned variable removes merge conflicts removes Examples headers introduced in 9b96de6 Revert "Fixed identation in actionmailer base_test" Report the correct value of nil.id in the exception message as different ruby implementations may have different values, for example Rubinius returns 53 for nil.id. Improve testing of cookies in functional tests: - cookies can be set using string or symbol keys - cookies are preserved across calls to get, post, etc. - cookie names and values are escaped - cookies can be cleared using @request.cookies.clear more style changes Some style changes style changes Revert "style changes" Raise ArgumentError if route name is invalid [#6517 state:resolved] style changes Allow model to be inherited from Hash [#6487 state:resolved] styles applied for usage added failing test for fields_for with a record object that inherits from Hash Fixed identation in actionmailer base_test wrong SQL statement commas to set off expressions that interrupt sentence flow typo changes ... https://github.com/rails/rails/commit/9cee693213e0205cb5992728bb516...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 6517 Named Routes in routes.rb shows syntax error in actionpack (from [2437c78f40d5e89aa3dc1c960bbe12fe0427b627]) Raise A...
- 6517 Named Routes in routes.rb shows syntax error in actionpack (from [e00867bc437b6a681491ef59e13423051e6d98f0]) Raise A...
- 6538 [PATCH] Fixed indentation in actionmailer base_test 'master' of github.com:rails/rails: (44 commits) Fixed in...
- 6517 Named Routes in routes.rb shows syntax error in actionpack 'master' of github.com:rails/rails: (44 commits) Fixed in...
- 6487 FormHelper should allow model to be inherited from hash 'master' of github.com:rails/rails: (44 commits) Fixed in...