Rails action don't redirect me to a external page

289 Views Asked by At

I have this link to redirect to google is a example , i just need to go to the controller and then make some insert in database and redirect to a torrent link but in the example just show google

<%= link_to "Link", {:controller => "home", :action => "index", :link=> "www.google.com" }%>

when i press the link i continue to the following action

> def index
>     @link = params[:link]
>     if @link.present?
>       return redirect_to @link
>     end 
> end

but the action don't redirect me to www.google.com just go to this direction

localhost:3000/?link=www.google.com

how can i go to www.google.com and redirect well ?

2

There are 2 best solutions below

0
On

I just need to specified the protocol in this case http

Now is working with this

<%= link_to "Link", {:controller => "home", :action => "index", :link => "http://www.google.cl" }%>
2
On

I think that you are looking for this:

<%= link_to "Link", "http://www.google.com" %>

Hope I could help.