Class: ActionDispatch::Routing::Mapper

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

Instance Method Summary collapse

Instance Method Details

#warning_paths_for(*resources) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/acts_as_warnable/rails/routes.rb', line 4

def warning_paths_for(*resources)
  resources.map(&:to_s).each do |resource|
    get "/#{resource.pluralize}/:warnable_id/warnings",
        to: 'acts_as_warnable/warnings#index',
        defaults: { warnable_type: resource.singularize.camelize },
        as: "#{resource.singularize}_warnings"

    post "/#{resource.pluralize}/:warnable_id/warnings",
         to: 'acts_as_warnable/warnings#post',
         defaults: { warnable_type: resource.singularize.camelize }
  end
end