Class: Shoppy::OptionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Shoppy::OptionsController
- Defined in:
- app/controllers/shoppy/options_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#delete ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/shoppy/options_controller.rb', line 50 def delete = OptionsGroup.find_by(id: params[:options_group_id]) if .destroy Log.newEvent("Option Groups", "Options group named '#options_group.name}' was deleted", current_admin.name) flash[:notice] = "Options' group has been deleted." redirect_to '/products/options' else page_not_found end end |
#edit ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/shoppy/options_controller.rb', line 32 def edit @options_group = OptionsGroup.find_by(id: params[:options_group_id]) if @options_group @options_group.name = params[:options_group][:name] @options_group.display = params[:options_group][:display] @options_group.items_string = params[:optionsItems] if @options_group.save Log.newEvent("Option Groups", "Options group named '#@options_group.name}' was updated", current_admin.name) flash[:notice] = "Options Group has been updated." else flash[:error] = @options_group.errors. end redirect_to '/products/options/' + @options_group.id.to_s else page_not_found end end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/shoppy/options_controller.rb', line 5 def index @options = OptionsGroup.all end |
#new ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/shoppy/options_controller.rb', line 9 def new if (params[:name]) && (params[:name] != "") && (params[:display]) && (params[:display] != "") && (params[:optionsItems]) && (params[:optionsItems] != "") if OptionsHelper::(params[:name], params[:display], params[:optionsItems]) Log.newEvent("Option Groups", "Options group named '#{params[:name]}' was created", current_admin.name) flash[:notice] = "Options Group has been created!" else flash[:warning] = "Something went wrong. Try again later" end else flash[:warning] = "Please make sure you have entered the options' group name, display name, and the options." end redirect_to "/products/options" end |
#show ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'app/controllers/shoppy/options_controller.rb', line 23 def show og = OptionsGroup.find_by(id: params[:options_group_id]) if og @options_group = og else page_not_found end end |