diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/call_route.rb | 8 | ||||
-rw-r--r-- | app/models/route_element.rb | 15 | ||||
-rw-r--r-- | app/views/call_routes/show.html.haml | 3 |
3 files changed, 23 insertions, 3 deletions
diff --git a/app/models/call_route.rb b/app/models/call_route.rb index de0f68a..f6a3dd3 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -1,4 +1,6 @@ class CallRoute < ActiveRecord::Base + ROUTING_TABLES = ['prerouting', 'outbound', 'inbound'] + attr_accessible :table, :name, :endpoint_type, :endpoint_id, :position has_many :route_elements, :dependent => :destroy @@ -6,6 +8,12 @@ class CallRoute < ActiveRecord::Base validates :name, :presence => true + validates :table, + :presence => true, + :inclusion => { :in => ROUTING_TABLES } + + acts_as_list :scope => '`table` = \'#{table}\'' + def to_s name.to_s end diff --git a/app/models/route_element.rb b/app/models/route_element.rb index 11bb54a..d3302ea 100644 --- a/app/models/route_element.rb +++ b/app/models/route_element.rb @@ -1,8 +1,23 @@ class RouteElement < ActiveRecord::Base + ELEMENT_ACTIONS = ['match', 'not_match', 'set_route_var', 'set_header'] + attr_accessible :call_route_id, :var_in, :var_out, :pattern, :replacement, :action, :mandatory, :position belongs_to :call_route + acts_as_list :scope => :call_route + + validates :var_in, + :presence => true + + validates :pattern, + :presence => true + + validates :action, + :presence => true, + :inclusion => { :in => ELEMENT_ACTIONS } + + def to_s "#{var_in} #{var_out}" end diff --git a/app/views/call_routes/show.html.haml b/app/views/call_routes/show.html.haml index c5c7397..8be64e6 100644 --- a/app/views/call_routes/show.html.haml +++ b/app/views/call_routes/show.html.haml @@ -12,9 +12,6 @@ %p %strong= t('call_routes.show.endpoint_id') + ":" = @call_route.endpoint_id -%p - %strong= t('call_routes.show.position') + ":" - = @call_route.position = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @call_route } |