Sha256: 12b65809f7d9b582889a39f86589cd1bd715b4cfe84b5983fc4ee576f72eefd2

Contents?: true

Size: 645 Bytes

Versions: 2

Compression:

Stored size: 645 Bytes

Contents

class ActionDispatch::Routing::Mapper
  def databound(*resources)
    namespace = @scope[:path]
    namespace = namespace[1..-1] if namespace
    opts = resources.pop if resources.last.is_a?(Hash)

    resources.each do |resource|
      Rails.application.routes.draw do
        controller = [namespace, resource].compact.join('/')
        Databound::Utils.create_controller_unless_exists(controller, resource, opts)

        %i(where create update destroy).each do |name|
          path = [namespace, resource, name].compact.join('/')
          to = [controller, name].join('#')
          post path => to
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
databound-2.0.1 lib/databound/rails/routes.rb
databound-2.0.0 lib/databound/rails/routes.rb