blob: 1fe61e967696a414967a316d86203b08dab62c11 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
class CallRoute < ActiveRecord::Base
# https://github.com/rails/strong_parameters
include ActiveModel::ForbiddenAttributesProtection
ROUTING_TABLES = ['prerouting', 'outbound', 'inbound']
has_many :route_elements, :dependent => :destroy
validates :name,
:presence => true
validates :routing_table,
:presence => true,
:inclusion => { :in => ROUTING_TABLES }
acts_as_list :scope => '`routing_table` = \'#{routing_table}\''
def to_s
name.to_s
end
def move_up?
return self.position.to_i > CallRoute.where(:routing_table => self.routing_table ).order(:position).first.position.to_i
end
def move_down?
return self.position.to_i < CallRoute.where(:routing_table => self.routing_table ).order(:position).last.position.to_i
end
end
|