Class: Shoppy::ManufacturersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Shoppy::ManufacturersController
- Defined in:
- app/controllers/shoppy/manufacturers_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#delete ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/shoppy/manufacturers_controller.rb', line 58 def delete @manufacturer = Manufacturer.find_by(id: params[:manufacturer_id]) if @manufacturer @manufacturer.destroy Log.newEvent("Manufacturers", "Manufacturer named '#{@manufacturer.name}' was deleted", current_admin.name) flash[:notice] = "Manufacturer has been deleted." redirect_to '/products/manufacturers' else page_not_found end end |
#edit ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/shoppy/manufacturers_controller.rb', line 41 def edit @manufacturer = Manufacturer.find_by(id: params[:manufacturer_id]) if @manufacturer if @manufacturer.update_attributes(category_params) Log.newEvent("Manufacturers", "Manufacturer named '#{@manufacturer.name}' was updated", current_admin.name) flash[:notice] = "Manufacturer has been updated." else flash[:error] = @manufacturer.errors. end redirect_to '/products/manufacturers/' + @manufacturer.id.to_s else page_not_found end end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/shoppy/manufacturers_controller.rb', line 5 def index @manufacturers = Manufacturer.all end |
#new ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/shoppy/manufacturers_controller.rb', line 9 def new @manufacturer = Manufacturer.new @manufacturer.name = params[:name] @manufacturer.phone = params[:phone] @manufacturer.email = params[:email] @manufacturer.website = params[:website] @manufacturer.add_line1 = params[:add_line1] @manufacturer.add_line2 = params[:add_line2] @manufacturer.city = params[:city] @manufacturer.state = params[:state] @manufacturer.country = params[:country] @manufacturer.zip = params[:zip] if @manufacturer.save Log.newEvent("Manufacturers", "A new manufacturer named '#{@manufacturer.name}' was created", current_admin.name) flash[:notice] = "Manufacturer has been created." else ## TODO: Handle Errors flash[:error] = @manufacturer.errors. end redirect_to '/products/manufacturers' end |
#show ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/controllers/shoppy/manufacturers_controller.rb', line 31 def show c = Manufacturer.find_by(id: params[:manufacturer_id]) if c @manufacturer = c else page_not_found end end |