I am a rails beginner and I am having trouble displaying external urls
on view.
This is what i have in DB for ex: www.rubyonrails.com, if i try to
construct the url on the page using link_to the url formed is -
http://localhost:3000/www.rubyonrails.com .
Can someone help me in fixing this issue.
Thanks
11175
(-- --)
April 19, 2008, 6:05am
2
<%= link_to @from_DB.name_url , "http://www.rubyonrails.com ", {:target =>
"_blank" } %>
is it your solution?
Rgd,
Reinhart
http://teapoci.blogspot.com
I tried that, but still doesn't work , the url formed is
http://localhost:3000/www.rubyonrails.com
This is what i have in the view
<% @url_list.each do |u| %>
<%= link_to u.url, "www.rubyonrails.com", {:target=>'_blank'} %>
<% end %>
11175
(-- --)
April 19, 2008, 6:43am
4
What do you want your url like ?
http://localhost:3000/www.rubyonrails.com
IF YES, flow to here :
{RAILS_ROOT}/config/route.rb
Add it :
map.web_url ':url_name',
:controller => 'my_controller', :action => 'my_action'
in your view :
<% @url_list.each do |u| %>
<%= link_to u.url, :action=>'my_action', :url_name => u.url %>
<% end %>
It will make your url in address bar to be
http://localhost:3000/www.rubyonrails.com
BUT THE SCRIPT BELOW, for accessing external url with new windows.
<% @url_list.each do |u| %>
<%= link_to u.url, u.url, {:target=>'_blank'} %>
<% end %>
Reinhart
http://teapoci.blogspot.com
marahddis
(marahddis)
April 19, 2008, 9:18am
5
Hi there,
Try putting the http:// before the URL
MD