Sha256: d5baa3e9021da3bcd75e49e4182719e6fd68823a74647a729822ffcfdb101986

Contents?: true

Size: 1005 Bytes

Versions: 4

Compression:

Stored size: 1005 Bytes

Contents

require 'rawbotz/routes'

module Rawbotz::RawbotzApp::Routing::Suppliers
  include RawgentoModels

  def self.registered(app)
    # app.get  '/suppliers', &show_suppliers
    show_suppliers = lambda do
      @suppliers = Supplier.all
      haml "suppliers/index".to_sym
    end

    # app.get  '/supplier/:id', &show_supplier
    show_supplier = lambda do
      @supplier = Supplier.find(params[:id])
      haml "supplier/view".to_sym
    end

    # app.post '/supplier/:id', &update_supplier
    update_supplier = lambda do
      @supplier = Supplier.find(params[:id])
      @supplier.email = params[:email]
      @supplier.order_template = params[:order_template]
      if @supplier.save
        add_flash :success, "Supplier updated"
      else
        add_flash :error, "Supplier could not be saved"
      end
      haml "supplier/view".to_sym
    end

    app.get  '/suppliers',    &show_suppliers
    app.get  '/supplier/:id', &show_supplier
    app.post '/supplier/:id', &update_supplier
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rawbotz-0.1.5 lib/rawbotz/routes/suppliers.rb
rawbotz-0.1.4 lib/rawbotz/routes/suppliers.rb
rawbotz-0.1.3 lib/rawbotz/routes/suppliers.rb
rawbotz-0.1.2 lib/rawbotz/routes/suppliers.rb