Sha256: 68859c239845ac6fed273cfecd4f1db2eb66f297a8822244e8abe28eee6aaf32

Contents?: true

Size: 950 Bytes

Versions: 2

Compression:

Stored size: 950 Bytes

Contents

class Manage::StructuresController < Manage::BaseController
  inherit_resources
  defaults :route_prefix => 'manage'
  
  before_filter :find_root, :only=>[:index]  
  
  load_and_authorize_resource
    
  cache_sweeper :structure_sweeper, :only=>[:create, :update, :destroy, :move]
  
  def create
    create!{ manage_structures_path }
  end
  
  def update
    update!{ manage_structures_path }
  end
  
  def destroy
    destroy!{ manage_structures_path }
  end
  
  # POST /manage/structures/1/move
  def move
    @structure = Structure.find(params[:id])
    @structure.move_by_direction(params[:direction])
    
    respond_with(@structure, :location => manage_structures_path)
  end
  
  protected
  
    def find_root
      @structure ||= Structure.with_kind(StructureType.main).with_depth(0).find(:first)
      @structure
    end
    
    def collection
      @structures = (@structures || end_of_association_chain).with_depth(1)
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
freeberry-0.3.0 app/controllers/manage/structures_controller.rb
freeberry-0.2.9 app/controllers/manage/structures_controller.rb