Skip to content

Instantly share code, notes, and snippets.

@libryder
Created March 9, 2012 03:28
Show Gist options
  • Select an option

  • Save libryder/2004854 to your computer and use it in GitHub Desktop.

Select an option

Save libryder/2004854 to your computer and use it in GitHub Desktop.
class CallFlow < ActiveRecord::Base
establish_connection "callengine_#{Rails.env}"
belongs_to :routable, :polymorphic => true
def dialplan
puts self.routable.description.squeeze("\n").strip
end
def target_route=(params)
self.routable = params[:kind].constantize.new(params.reject {|k,v| k == "kind"})
end
end
case params[:route_type]
when "simple"
# Setup the nested attributes to pass to the models and create a callflow
# validate_hash is a flat hash of attributes meant for the CallFlow model
@nested_attributes = validate_hash[:criteria].merge({
'target_route' => {
'kind' => 'RouteByMessage',
'message_options_attributes' => {
'message' => message,
'target_did' => ringto
}
}
})
call_flow = CallFlow.create(@nested_attributes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment