Module: Hemp::Routing::RouteExtensions

Included in:
Base
Defined in:
lib/hemp/routing/route_extensions.rb

Instance Method Summary collapse

Instance Method Details

#resources(*subjects) ⇒ Object



4
5
6
7
8
# File 'lib/hemp/routing/route_extensions.rb', line 4

def resources(*subjects)
  subjects.each do |subject|
    subject_helper subject
  end
end

#subject_helper(subject) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/hemp/routing/route_extensions.rb', line 10

def subject_helper(subject)
  get "/#{subject}", to: "#{subject}#index"
  get "/#{subject}/new", to: "#{subject}#new"
  post "/#{subject}", to: "#{subject}#create"
  get "/#{subject}/:id", to: "#{subject}#show"
  get "/#{subject}/:id/edit", to: "#{subject}#edit"
  patch "/#{subject}/:id", to: "#{subject}#update"
  put "/#{subject}/:id", to: "#{subject}#update"
  delete "/#{subject}/:id", to: "#{subject}#destroy"
end