hughevans.net - hughevans.net

Example domain paragraphs

I was browsing Github today when I noticed the URL pattern they had employed for Pull Requests 2.0 . The index is at /pulls as you’d expect, however the show action was in the format of /pull/1 . Here’s an example . I actually think it’s rather nice and reads better than the Rails default of /pulls/1 .

Here is how to corral Rails into giving you these types of links for a collection and a nested collection (excuse the Ruby 1.9 hash syntax):

match 'jobs' => 'jobs#index', as: :jobs match 'jobs' => 'jobs#create', via: :post resources :job, controller: 'jobs', except: [:index, :create] do match 'items' => 'items#index', as: :items match 'items' => 'items#create', via: :post resources :item, controller: 'items', except: [:index, :create] end This gives you the following: