Reputation: 7419
In rails, when I have a form with a path-helper, for instance create_admin_shop_voucher_path
and I want to find out what controller action it points to, I look in routes.rb:
rake routes | grep 'create_admin_shop_voucher'
But how do I do the same for a url-helper, for instance passed_url
?
Upvotes: 2
Views: 151
Reputation: 4927
Lets say you have this route in your RAILS_ROOT/config/routes.rb
file
get "passed" => "passed#index", :as => :passed
If you call passed_url
rails will return the whole url. For instance http://localhost:3000/passed
if you call passed_path
rails will return the relative path /passed
*_url helper generates a URL that includes the protocol and host name. The *_path helper generates only the path portion.
So, the its the same route in your RAILS_ROOT/config/routes.rb
file
In your case you can call create_admin_shop_voucher_url
as well as create_admin_shop_voucher_path
.
Mostly you should use the _path flavor. If you need to spec the host or protocol (like for talking to another app or service), then use the _url flavor.
I use _url when i want to pass for instance a subdomain to a link.
Upvotes: 1