Sha256: 27880200e5287bc219467d25102c662aef5177cd9a587ad22f8855020267a07d

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

ActionDispatch::Routing::Mapper::Resources::Resource.class_eval do
  self::NEW_DEFAULT_ACTIONS = (self::DEFAULT_ACTIONS << [:select, :multi_update]).flatten!
    
  def default_actions
    self.class::NEW_DEFAULT_ACTIONS
  end
end

ActionDispatch::Routing::Mapper::Resources.class_eval do
  def resources(*resources, &block)
    options = resources.extract_options!
    
    if apply_common_behavior_for(:resources, resources, options, &block)
      return self
    end
    
    resource_scope(Resource.new(resources.pop, options)) do
      yield if block_given?
    
      collection do
        get  :index if parent_resource.actions.include?(:index)
        post :create if parent_resource.actions.include?(:create)
        put  :multi_update if parent_resource.actions.include?(:multi_update)
      end
    
      new do
        get :new
      end if parent_resource.actions.include?(:new)
    
      member do
        get    :edit if parent_resource.actions.include?(:edit)
        get    :show if parent_resource.actions.include?(:show)
        put    :update if parent_resource.actions.include?(:update)
        delete :destroy if parent_resource.actions.include?(:destroy)
      end
    end
    
    self
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multi-updator-0.0.5 lib/multi-updator/routes.rb