Class: DmEvent::Admin::WorkshopPricesController
- Inherits:
-
AdminController
- Object
- AdminController
- DmEvent::Admin::WorkshopPricesController
- Includes:
- PermittedParams
- Defined in:
- app/controllers/dm_event/admin/workshop_prices_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
——————————————————————————.
-
#destroy ⇒ Object
——————————————————————————.
-
#edit ⇒ Object
——————————————————————————.
-
#index ⇒ Object
——————————————————————————.
-
#new ⇒ Object
——————————————————————————.
-
#sort ⇒ Object
——————————————————————————.
-
#update ⇒ Object
——————————————————————————.
Methods included from PermittedParams
#registration_params, #system_email_params, #workshop_params, #workshop_price_params
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/dm_event/admin/workshop_prices_controller.rb', line 25 def create :manage_events, @workshop attributes = WorkshopPrice.prepare_prices(workshop_price_params.merge(price_currency: @workshop.base_currency)) @workshop_price = @workshop.workshop_prices.new(attributes) if @workshop_price.save redirect_to admin_workshop_workshop_prices_url(@workshop), notice: 'Price was successfully created.' else render action: :new end end |
#destroy ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/dm_event/admin/workshop_prices_controller.rb', line 48 def destroy :manage_events, @workshop if @workshop_price.registrations.count == 0 @workshop_price.destroy redirect_to admin_workshop_workshop_prices_url(@workshop), notice: 'Price was successfully deleted.' else redirect_to admin_workshop_workshop_prices_url(@workshop), error: 'Registrations are using this price - unable to delete' end end |
#edit ⇒ Object
20 21 22 |
# File 'app/controllers/dm_event/admin/workshop_prices_controller.rb', line 20 def edit :manage_events, @workshop end |
#index ⇒ Object
8 9 10 11 |
# File 'app/controllers/dm_event/admin/workshop_prices_controller.rb', line 8 def index :manage_events, @workshop @workshop_prices = @workshop.workshop_prices end |
#new ⇒ Object
14 15 16 17 |
# File 'app/controllers/dm_event/admin/workshop_prices_controller.rb', line 14 def new :manage_events, @workshop @workshop_price = @workshop.workshop_prices.build(price_currency: @workshop.base_currency) end |
#sort ⇒ Object
59 60 61 62 63 64 |
# File 'app/controllers/dm_event/admin/workshop_prices_controller.rb', line 59 def sort @workshop_price.update_attribute(:row_order_position, params[:item][:row_order_position]) #--- this action will be called via ajax render nothing: true end |
#update ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/dm_event/admin/workshop_prices_controller.rb', line 37 def update :manage_events, @workshop attributes = WorkshopPrice.prepare_prices(workshop_price_params.merge(price_currency: @workshop.base_currency)) if @workshop_price.update_attributes(attributes) redirect_to admin_workshop_workshop_prices_url(@workshop), notice: 'Price was successfully updated.' else render action: :edit end end |