Sha256: 897b3b85af5439d7412fec1495115832ae381f3a48d99be1e06cfb1f8967c99a

Contents?: true

Size: 960 Bytes

Versions: 1

Compression:

Stored size: 960 Bytes

Contents

class Admin::BillingIntegrationsController < Admin::BaseController
  resource_controller
  before_filter :load_data

  update.before do
		if params[:billing_integration] && params[:billing_integration][:type] && @object.type.to_s != params[:billing_integration][:type]
			@object.type = params[:billing_integration][:type]
			@object.save
			
			load_object			
		end
 		@object.update_attributes params[@object.class.name.underscore.gsub("/", "_")]
  end

  update.wants.html { redirect_to edit_object_url }
  create.wants.html { redirect_to edit_object_url }

  private       
  def build_object
		if params[:billing_integration] && params[:billing_integration][:type]
			@object ||= params[:billing_integration][:type].constantize.send parent? ? :build : :new, object_params 
		else
			@object ||= end_of_association_chain.send parent? ? :build : :new, object_params 
		end
  end
  
  def load_data   
    @providers = BillingIntegration.providers
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree-enriquez-0.9.4 app/controllers/admin/billing_integrations_controller.rb