Sha256: ddc5bd4954c11561b333caa21817af9b146aa12bedc2c5b522a948948d4197fb

Contents?: true

Size: 965 Bytes

Versions: 3

Compression:

Stored size: 965 Bytes

Contents

class Manage::StructuresController < Manage::BaseController
  inherit_resources
  
  before_filter :find_root, :only=>[:index]  
    
  defaults :route_prefix => 'manage'
  
  filter_access_to :move, :require => :update
  
  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 ||= end_of_association_chain.with_depth(1).find(:all)
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
freeberry-0.2.7 app/controllers/manage/structures_controller.rb
freeberry-0.2.6 app/controllers/manage/structures_controller.rb
freeberry-0.2.5 app/controllers/manage/structures_controller.rb