Sha256: a558871ca544951ab0fcecd254d392a1c566e6865886043f064885d314d984fa

Contents?: true

Size: 1.02 KB

Versions: 17

Compression:

Stored size: 1.02 KB

Contents

class MembershipChangesController < ApplicationController
  before_filter :set_person, :only => [:create]

  def create
    change = MembershipChange.new(membership_change_params)
    if change.save
      # Success!
      flash[:success] = 'Memberships have been successfully changed.'
    else
      # Error!
      flash[:error] = error_message
    end
  rescue Exception => e
    Rails.logger.info(e.message)
    Rails.logger.info(e.backtrace.join("\n"))

    flash[:error] = error_message
  ensure
    redirect_to person_memberships_path(@person)
  end

  private
  def error_message
    "We're sorry but we could not process the change.  Please make sure all fields are filled out accurately."
  end

  def membership_change_params
    permitted = [:membership_ids, :membership_type_id, :price, :payment_method, :credit_card_info, :person_id]
    permitted.reduce({}) do |all,key|
      all[key] = params[key] if params[key].present?
      all
    end
  end

  def set_person
    @person = Person.find(params[:person_id])
    true
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
artfully_ose-1.3.0.pre4 app/controllers/membership_changes_controller.rb
artfully_ose-1.3.0.pre3 app/controllers/membership_changes_controller.rb
artfully_ose-1.3.0.pre2 app/controllers/membership_changes_controller.rb
artfully_ose-1.3.0.pre1 app/controllers/membership_changes_controller.rb
artfully_ose-1.2.0 app/controllers/membership_changes_controller.rb
artfully_ose-1.2.0.beta.1 app/controllers/membership_changes_controller.rb
artfully_ose-1.2.0.alpha.2 app/controllers/membership_changes_controller.rb
artfully_ose-1.2.0.alpha.1 app/controllers/membership_changes_controller.rb
artfully_ose-1.2.0.pre.27 app/controllers/membership_changes_controller.rb
artfully_ose-1.2.0.pre.26 app/controllers/membership_changes_controller.rb
artfully_ose-1.2.0.pre.24 app/controllers/membership_changes_controller.rb
artfully_ose-1.2.0.pre.23 app/controllers/membership_changes_controller.rb
artfully_ose-1.2.0.pre.21 app/controllers/membership_changes_controller.rb
artfully_ose-1.2.0.pre.20 app/controllers/membership_changes_controller.rb
artfully_ose-1.2.0.pre.19 app/controllers/membership_changes_controller.rb
artfully_ose-1.2.0.pre.18 app/controllers/membership_changes_controller.rb
artfully_ose-1.2.0.pre.17 app/controllers/membership_changes_controller.rb