Skip to content

Instantly share code, notes, and snippets.

@Sephi-Chan
Created May 8, 2012 16:44
Show Gist options
  • Save Sephi-Chan/2637148 to your computer and use it in GitHub Desktop.
Save Sephi-Chan/2637148 to your computer and use it in GitHub Desktop.
Generating routes VS Writing routes by hand
Application::Application.routes.draw do
get '/my_favorites', to: 'favorites#my_index'
resources :users do
resources :favorites, only: [ :index ]
end
resources :favorites, only: [ :destroy ]
namespace :bookmarklet do
resources :favorites, only: [ :new, :create ]
end
end
Application::Application.routes.draw do
delete '/favorites/:id', to: 'favorites#destroy', as: 'favorite'
get '/users/:user_id/favorites', to: 'favorites#index', as: 'user_favorites'
get '/my/favorites', to: 'favorites#my_index', as: 'my_favorites'
get '/bookmarklet/favorites/new', to: 'bookmarklet/favorites#new', as: 'bookmarklet_new_favorite'
post '/bookmarklet/favorites', to: 'bookmarklet/favorites#create', as: 'bookmarklet_favorites'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment