ruby on rails - Routing to a page from JavaScript side -
currently this:
+ var go_to = "http://localhost:3000" + url; + window.open(go_to);
which takes index action of rail controller , shows page.
two things want improve: 1- hard coding "http://localhost:3000"
dead wrong. right way?
2- there better way of talking rails js side open new window?
to go web root, use:
window.location = '/';
you can other page, such as:
window.location = '/about/';
starting destination '/' change page within site / current domain. locally it'll localhost:3000/
when live on server, go http://www.mydomain.com/
also if you're looking better way talk rails urls application, can use routes variables. in console run rake routes
, it'll list routes have. variable root_path
return /
or whatever root path may set within app.
<%= link_to "home", root_path, target: '_blank' %>
Comments
Post a Comment