Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/record_collection/rails/routes.rb

Instance Method Summary collapse

Instance Method Details

#collection_resources(*resources, &blk) ⇒ Object

Add two collection routes to the normal resources definition. This call behaves exactly as the normal resources :… call, but adds:

collection do
  get :collection_edit
  post :collection_update
end


10
11
12
13
14
15
16
17
18
19
# File 'lib/record_collection/rails/routes.rb', line 10

def collection_resources(*resources, &blk)
  collection_blk = Proc.new do
    collection do
      get :collection_edit
      match :collection_update, via: [:post, :patch, :put]
    end
    blk.call if blk
  end
  resources(*resources, &collection_blk)
end