Module: DynamicImage::Routing

Defined in:
lib/dynamic_image/routing.rb

Overview

DynamicImage Routing

Extends ActionDispatch::Routing::Mapper and provides a shortcut for defining routes for DynamicImage::Controller.

Instance Method Summary collapse

Instance Method Details

#image_resources(resource_name, options = {}) ⇒ Object

Declares an image resource.

image_resources :avatars

12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dynamic_image/routing.rb', line 12

def image_resources(resource_name, options = {})
  options = {
    path:        "#{resource_name}/:digest(/:size)",
    constraints: { size: /\d+x\d+/ },
    only:        [:show]
  }.merge(options)
  resources resource_name, options do
    get :uncropped, on: :member
    get :original, on: :member
    get :download, on: :member
  end
end