diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-01-18 08:13:32 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-01-18 08:13:32 +0100 |
commit | f4abcadbee2dac3f2d8e4dc710af364300aa41bf (patch) | |
tree | f4e4d52c647e21c9f98d617e903d05aa72fdc130 | |
parent | 17206a20e5bcb44fa4d90f0e176f7aa0fe43bca3 (diff) | |
parent | 73c9984510d572030329d967e44c6adb00d98613 (diff) |
Merge branch 'strong_parameter' into develop
-rw-r--r-- | app/controllers/call_routes_controller.rb | 9 | ||||
-rw-r--r-- | app/controllers/gs_parameters_controller.rb | 8 | ||||
-rw-r--r-- | app/models/call_route.rb | 7 | ||||
-rw-r--r-- | db/migrate/20130116133243_create_call_routes.rb | 2 | ||||
-rw-r--r-- | db/migrate/20130116203000_set_prerouting_table.rb | 92 | ||||
-rw-r--r-- | db/migrate/20130117191840_change_column_name_in_call_route.rb | 8 |
6 files changed, 65 insertions, 61 deletions
diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index 130a160..89f66ba 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -15,7 +15,7 @@ class CallRoutesController < ApplicationController end def create - @call_route = CallRoute.new(params[:call_route]) + @call_route = CallRoute.new(call_route_parameter_params[:call_route]) if @call_route.save redirect_to @call_route, :notice => t('call_routes.controller.successfuly_created') else @@ -27,7 +27,7 @@ class CallRoutesController < ApplicationController end def update - if @call_route.update_attributes(params[:call_route]) + if @call_route.update_attributes(call_route_parameter_params[:call_route]) redirect_to @call_route, :notice => t('call_routes.controller.successfuly_updated') else render :edit @@ -40,6 +40,10 @@ class CallRoutesController < ApplicationController end private + def call_route_parameter_params + params.require(:call_route).permit(:id, :routing_table, :name, :endpoint_type, :endpoint_id, :position) + end + def spread_breadcrumbs add_breadcrumb t("call_routes.index.page_title"), call_routes_path if @call_route && !@call_route.new_record? @@ -47,4 +51,5 @@ class CallRoutesController < ApplicationController end end + end diff --git a/app/controllers/gs_parameters_controller.rb b/app/controllers/gs_parameters_controller.rb index 7ca4e8e..3c212c1 100644 --- a/app/controllers/gs_parameters_controller.rb +++ b/app/controllers/gs_parameters_controller.rb @@ -10,7 +10,7 @@ class GsParametersController < ApplicationController end def show - @gs_parameter = GsParameter.find(params[:id]) + @gs_parameter = GsParameter.find(gs_parameter_params[:id]) end def new @@ -18,11 +18,11 @@ class GsParametersController < ApplicationController end def edit - @gs_parameter = GsParameter.find(params[:id]) + @gs_parameter = GsParameter.find(gs_parameter_params[:id]) end def update - @gs_parameter = GsParameter.find(params[:id]) + @gs_parameter = GsParameter.find(gs_parameter_params[:id]) if @gs_parameter.update_attributes(gs_parameter_params) redirect_to @gs_parameter, :notice => t('gs_parameters.controller.successfuly_updated') else @@ -32,7 +32,7 @@ class GsParametersController < ApplicationController private def gs_parameter_params - params.require(:gs_parameter).permit(:value, :class_type, :description) + params.require(:gs_parameter).permit(:id, :value, :class_type, :description) end def spread_breadcrumbs diff --git a/app/models/call_route.rb b/app/models/call_route.rb index 0df961d..5d90901 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -1,14 +1,15 @@ class CallRoute < ActiveRecord::Base - ROUTING_TABLES = ['prerouting', 'outbound', 'inbound'] + # https://github.com/rails/strong_parameters + include ActiveModel::ForbiddenAttributesProtection - attr_accessible :routing_table, :name, :endpoint_type, :endpoint_id, :position + ROUTING_TABLES = ['prerouting', 'outbound', 'inbound'] has_many :route_elements, :dependent => :destroy validates :name, :presence => true - validates :table, + validates :routing_table, :presence => true, :inclusion => { :in => ROUTING_TABLES } diff --git a/db/migrate/20130116133243_create_call_routes.rb b/db/migrate/20130116133243_create_call_routes.rb index c2d3f45..c2feda8 100644 --- a/db/migrate/20130116133243_create_call_routes.rb +++ b/db/migrate/20130116133243_create_call_routes.rb @@ -1,7 +1,7 @@ class CreateCallRoutes < ActiveRecord::Migration def self.up create_table :call_routes do |t| - t.string :table + t.string :routing_table t.string :name t.string :endpoint_type t.integer :endpoint_id diff --git a/db/migrate/20130116203000_set_prerouting_table.rb b/db/migrate/20130116203000_set_prerouting_table.rb index 86137a0..8b0365f 100644 --- a/db/migrate/20130116203000_set_prerouting_table.rb +++ b/db/migrate/20130116203000_set_prerouting_table.rb @@ -1,99 +1,99 @@ class SetPreroutingTable < ActiveRecord::Migration def up - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*0%*$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*0%*$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*0%*$', :replacement => 'f-li', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*0%*(%d+)#*$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*0%*(%d+)#*$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*0%*(%d+)#*$', :replacement => 'f-li-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*0%*(%d+)%*(%d+)#*$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*0%*(%d+)%*(%d+)#*$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*0%*(%d+)%*(%d+)#*$', :replacement => 'f-li-%1-%2', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#0#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#0#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#0#$', :replacement => 'f-lo', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*5%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*5%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*5%*(%d+)#$', :replacement => 'f-acdmtg-0-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*30#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*30#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*30#$', :replacement => 'f-clipon', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#30#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#30#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#30#$', :replacement => 'f-clipoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*31#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*31#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*31#$', :replacement => 'f-cliroff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#31#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#31#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#31#$', :replacement => 'f-cliron', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*31#(%d+)$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*31#(%d+)$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*31#(%d+)$', :replacement => 'f-dcliroff-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#31#(%d+)$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#31#(%d+)$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#31#(%d+)$', :replacement => 'f-dcliron-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*43#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*43#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*43#$', :replacement => 'f-cwaon', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#43#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#43#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#43#$', :replacement => 'f-cwaoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#002#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#002#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#002#$', :replacement => 'f-cfoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^##002#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##002#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##002#$', :replacement => 'f-cfdel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*21#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*21#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*21#$', :replacement => 'f-cfu', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*21%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*21%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*21%*(%d+)#$', :replacement => 'f-cfu-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*21%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*21%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*21%*(%d+)#$', :replacement => 'f-cfu-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#21#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#21#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#21#$', :replacement => 'f-cfuoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^##21#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##21#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##21#$', :replacement => 'f-cfudel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*61#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*61#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*61#$', :replacement => 'f-cfn', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*61%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*61%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*61%*(%d+)#$', :replacement => 'f-cfn-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*61%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*61%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*61%*(%d+)#$', :replacement => 'f-cfn-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*61%*(%d+)%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*61%*(%d+)%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*61%*(%d+)%*(%d+)#$', :replacement => 'f-cfn-%1-%2', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*61%*(%d+)%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*61%*(%d+)%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*61%*(%d+)%*(%d+)#$', :replacement => 'f-cfn-%1-%2', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#61#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#61#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#61#$', :replacement => 'f-cfnoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^##61#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##61#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##61#$', :replacement => 'f-cfndel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*62#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*62#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*62#$', :replacement => 'f-cfo', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*62%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*62%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*62%*(%d+)#$', :replacement => 'f-cfo-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*62%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*62%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*62%*(%d+)#$', :replacement => 'f-cfo-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#62#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#62#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#62#$', :replacement => 'f-cfooff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^##62#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##62#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##62#$', :replacement => 'f-cfodel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*67#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*67#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*67#$', :replacement => 'f-cfb', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*67%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*67%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*67%*(%d+)#$', :replacement => 'f-cfb-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*%*67%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*%*67%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*%*67%*(%d+)#$', :replacement => 'f-cfb-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^#67#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^#67#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^#67#$', :replacement => 'f-cfboff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^##67#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^##67#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^##67#$', :replacement => 'f-cfbdel', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*66#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*66#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*66#$', :replacement => 'f-redial', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*98$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*98$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*98$', :replacement => 'f-vmcheck', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*98#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*98#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*98#$', :replacement => 'f-vmcheck', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*98%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*98%*(%d+)#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*98%*(%d+)#$', :replacement => 'f-vmcheck-%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*1337%*1%*1#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*1337%*1%*1#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*1337%*1%*1#$', :replacement => 'f-loaon', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'feature code ^%*1337%*1%*0#$', :endpoint_type => 'dialplanfunction').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'feature code ^%*1337%*1%*0#$', :endpoint_type => 'dialplanfunction').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^%*1337%*1%*0#$', :replacement => 'f-loaoff', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'international prefix', :endpoint_type => 'phonenumber').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'international prefix', :endpoint_type => 'phonenumber').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^00(%d+)$', :replacement => '+%1', :action => 'set_route_var', :mandatory => true) - CallRoute.create(:table => 'prerouting', :name => 'national prefix', :endpoint_type => 'phonenumber').route_elements. + CallRoute.create(:routing_table => 'prerouting', :name => 'national prefix', :endpoint_type => 'phonenumber').route_elements. create(:var_in => 'destination_number', :var_out => 'destination_number', :pattern => '^0(%d+)$', :replacement => '+49%1', :action => 'set_route_var', :mandatory => true) end def down - CallRoute.where(:table => "prerouting").destroy_all + CallRoute.where(:routing_table => "prerouting").destroy_all end end diff --git a/db/migrate/20130117191840_change_column_name_in_call_route.rb b/db/migrate/20130117191840_change_column_name_in_call_route.rb index cad0f59..bbc4f28 100644 --- a/db/migrate/20130117191840_change_column_name_in_call_route.rb +++ b/db/migrate/20130117191840_change_column_name_in_call_route.rb @@ -1,9 +1,7 @@ class ChangeColumnNameInCallRoute < ActiveRecord::Migration def up - rename_column :call_routes, :table, :routing_table - end - - def down - rename_column :call_routes, :routing_table, :table + if column_exists?(:call_routes, :table) + rename_column :call_routes, :table, :routing_table + end end end |