Class: Admin::PaymentMethodsController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Admin::PaymentMethodsController
- Defined in:
- app/controllers/admin/payment_methods_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/admin/payment_methods_controller.rb', line 5 def create @payment_method = params[:payment_method][:type].constantize.new(params[:payment_method]) @object = @payment_method invoke_callbacks(:create, :before) if @payment_method.save invoke_callbacks(:create, :after) flash[:notice] = I18n.t(:successfully_created, :resource => I18n.t(:payment_method)) respond_with(@payment_method, :location => edit_admin_payment_method_path(@payment_method)) else invoke_callbacks(:create, :fails) respond_with(@payment_method) end end |
#update ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/admin/payment_methods_controller.rb', line 19 def update invoke_callbacks(:update, :before) payment_method_type = params[:payment_method].delete(:type) if @payment_method['type'].to_s != payment_method_type @payment_method.update_attribute(:type, payment_method_type) @payment_method = PaymentMethod.find(params[:id]) end payment_method_params = params[@payment_method.class.name.underscore.gsub("/", "_")] || {} if @payment_method.update_attributes(params[:payment_method].merge(payment_method_params)) invoke_callbacks(:update, :after) flash[:notice] = I18n.t(:successfully_updated, :resource => I18n.t(:payment_method)) respond_with(@payment_method, :location => edit_admin_payment_method_path(@payment_method)) else invoke_callbacks(:update, :fails) respond_with(@payment_method) end end |