Class: MembershipTypesController
- Inherits:
-
ArtfullyOseController
- Object
- ActionController::Base
- ArtfullyOseController
- MembershipTypesController
- Defined in:
- app/controllers/membership_types_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/membership_types_controller.rb', line 25 def create @membership_type = Kernel.const_get(params[:membership_type][:type].camelize).new(params[:membership_type]) @membership_type.organization = current_organization unless @membership_type.save flash[:error] = @membership_type.errors..to_sentence # @membership_type = Kernel.const_get(params[:membership_type][:type].camelize).new render "new" and return end redirect_to membership_types_path end |
#edit ⇒ Object
36 37 38 |
# File 'app/controllers/membership_types_controller.rb', line 36 def edit @membership_type = MembershipType.find(params[:id]) end |
#index ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/membership_types_controller.rb', line 4 def index @membership_types = current_organization.membership_types.paginate(:page => params[:page], :per_page => 50) respond_to do |format| format.html format.csv do @filename = 'membership_types.csv' @csv_string = @membership_types.to_comma send_data @csv_string, :filename => @filename, :type => 'text/csv', :disposition => 'attachment' end end end |
#new ⇒ Object
18 19 20 21 22 23 |
# File 'app/controllers/membership_types_controller.rb', line 18 def new with_type_selected do @membership_type = Kernel.const_get(params[:type].camelize).new @membership_type.hide_fee = true end end |
#update ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/membership_types_controller.rb', line 40 def update @membership_type = MembershipType.find(params[:id]) if @membership_type.update_attributes(params[:membership_type]) flash[:notice] = "Your changes have been saved" redirect_to membership_types_path else flash[:error] = @membership_type.errors..to_sentence render "edit" and return end end |