Error using wildcards and redirect on routes in Rails
ruby-on-rails
Solution
Wildcard components need to have a "label" as well, e.g.
match "/myroute*something" => redirect("http://google.com"), :as => :myroute
will match `/myrouteblah` and `/myroute/hello/world` where `params[:something]` is `blah` and `/hello/world` respectively.
EDIT: Check out http://guides.rubyonrails.org/v3.2/routing.html#route-globbing if you haven't already.
Problem
``` match "/myroute*" => redirect("http://google.com"), :as => :myroute ``` The line above in `routes.rb` is causing the following error ``` /Users/user/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/racc/parser.rb:349:in `on_error': (Racc::ParseError) parse error on value ")" (RPAREN) from /Users/user/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/racc/parser.rb:99:in `_racc_do_parse_c' from /Users/user/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/racc/parser.rb:99:in `do_parse' ``` Looks like it is because I'm adding a wildcard (*). Any idea how to solve this?