I know rails uses the controller action style urls like www.myapp.com/home/index for example
I would like to have a url like this on my rails app, www.myapp.com/my_page_here is this possible and if so how would I go about this?
I know rails uses the controller action style urls like www.myapp.com/home/index for example I
Share
You just use a
getoutside of anyresourcesornamespaceblock in yourroutes.rbfile:Assuming you are using Rails 3+, do NOT use
match. It can be dangerous, because if a page accepts data from a form, it should take POST requests.matchwould allow GET requests on an action with side-effects – which is NOT good.Always use
get,put,postor these variants where possible.To get a path helper, try:
That way, in your views,
my_page_pathwill equalhttp://{domain}/my_page_here