Custom url in ruby on rails

I know rails uses the controller action style urls like for example I would like to have a url like this on my rails app, is this possible and if so how would I go about this?


You just use a get outside of any resources or namespace block in your routes.rb file:

get 'my_page_here ', :to => 'home#index'

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. match would allow GET requests on an action with side-effects - which is NOT good.

Always use get, put, post or these variants where possible.

To get a path helper, try:

get 'my_page_here ', :to => 'home#index', :as => :my_page

That way, in your views, my_page_path will equal http://{domain}/my_page_here

Need Your Help

Understanding Backbone and Marionette View lifecycle

javascript backbone.js marionette lifecycle backbone-views

I'm new to this world and I need to understand some of the concepts of Backbone and Marionette. Here I'm trying to explain some of the concepts I'm learning. It would be great to having some feedba...

Linq query to group by field1, count field2 and filter by count between values of joined collection

c# linq linq-to-objects

I'm having trouble with getting a my linq query correct. I've been resisting doing this with foreach loops because I'm trying to better understand linq.