Module: ConstructorPages::MoveHelper

Included in:
PagesController, TemplatesController
Defined in:
app/helpers/constructor_pages/move_helper.rb

Instance Method Summary collapse

Instance Method Details

#move_to(what, id, to) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/constructor_pages/move_helper.rb', line 3

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