Reputation: 14504
I am trying to create a route and a action that redirects the params.
Example when a user visits: www.mywebsite.com/photographer/flv/:ID/:filename
I want the user to be redirected to: www.someotherwebsite.com/photographer/flv/:ID/:filename
I have tried to accomplish with this solution without luck:
My controller URL:
def videore
redirect_to www.whateverwebsite.com + params[:all]
end
And in routes:
match '/photographer/flv/:ID/:filename' => 'URL#videore'
Upvotes: 0
Views: 101
Reputation: 6444
From the Ruby on Rails Guide:
match "/stories/:name" => redirect("/posts/%{name}")
In all of these cases, if you don’t provide the leading host (http://www.example.com), Rails will take those details from the current request.
So redirecting to another TLD should work like this (no action in your controller required):
match '/photographer/flv/:ID/:filename' => redirect("http://www.someotherwebsite.com/photographer/flv/%{ID}/%{filename}")
Upvotes: 0
Reputation: 12605
This should do it:
In your controller action:
def videore
redirect_to "http://www.whateverwebsite.com/photographer/flv/#{params[:id]}/#{params[:filename]}"
end
And in routes:
match '/photographer/flv/:id/:filename' => 'url#videore'
This assumes, of course, that 'url' is the name of your controller
Upvotes: 1