Sha256: e5f829e3ac69a50bac3cb5421542a011911b136c4fc36eb83176ce6e70c574e0

Contents?: true

Size: 596 Bytes

Versions: 39

Compression:

Stored size: 596 Bytes

Contents

# encoding: utf-8

module ConstructorPages
  class ApplicationController < ConstructorCore::ApplicationController
    def self.movable(what)
      %w{up down}.each {|m| define_method "move_#{m}" do move_to what, params[:id], m.to_sym end}
    end

    def move_to(what, id, to)
      from = ('constructor_pages/'+what.to_s).classify.constantize.find(id)
      to_sibling = to == :up ? from.left_sibling : from.right_sibling

      if not to_sibling.nil? and from.move_possible?(to_sibling)
        to == :up ? from.move_left : from.move_right
      end

      redirect_to :back
    end
  end
end

Version data entries

39 entries across 39 versions & 3 rubygems

Version Path
constructor-pages-0.9.1 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.9.0 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.19 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.18 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.17 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.16 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.15 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.14 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.13 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.12 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.11 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.10 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.8 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.7 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.6 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.5 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.4 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.3 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.2 app/controllers/constructor_pages/application_controller.rb
constructor-pages-0.8.1 app/controllers/constructor_pages/application_controller.rb