Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request not being optional on routes #5677

Closed
fedesoria opened this issue Mar 31, 2012 · 3 comments
Closed

Request not being optional on routes #5677

fedesoria opened this issue Mar 31, 2012 · 3 comments

Comments

@fedesoria
Copy link
Contributor

The following will raise ArgumentError (wrong number of arguments (1 for 2))

match '/redirect/:id', :to => redirect {|params| "/hello/#{User.find(params[:id]).name}"}

this was fixed when introduced |params, request|

Found out that that 6c57177 this commit fixes the problem but hasn't been pushed to a release.

Gracias.

@rafaelfranca
Copy link
Member

The redirect blocks with one argument is deprecated. You should use with two arguments like this:

match '/redirect/:id', :to => redirect {|params, request| "/hello/#{User.find(params[:id]).name}"}

@drogus
Copy link
Member

drogus commented Mar 31, 2012

The commit that you linked to actually just removed deprecation. request as optional parameter was deprecated and it's removed in master. You can still pass only one parameter on 3.2.x, but you will get deprecation warning: https://github.com/rails/rails/blob/3-2-stable/actionpack/lib/action_dispatch/routing/redirection.rb#L102

Does it clear things out or is your problem different?

@rafaelfranca
Copy link
Member

Hey guys, I confirmed that when you pass only one argument to the redirect block one exception is raised. I'm working on it to fix and reopening this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants