Class: Redirect

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/rest-assured/models/redirect.rb

Class Method Summary collapse

Class Method Details

.update_order(ordered_redirect_ids) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rest-assured/models/redirect.rb', line 11

def self.update_order(ordered_redirect_ids)
  success = true

  transaction do
    begin
      update_all :position => nil

      ordered_redirect_ids.each_with_index do |r_id, idx|
        r = find(r_id)
        r.position = idx
        r.save!
      end
    rescue
      # TODO log exception
      success = false
      raise ActiveRecord::Rollback
    end
  end
  success
end