Files
mozo-backend/app/controllers/new_suppliers_controller.rb
T
2015-02-24 17:56:06 +01:00

25 lines
594 B
Ruby

class NewSuppliersController < ApplicationController
def index
new
render 'new'
end
def new
@new_supplier = NewSupplier.new
@new_supplier.current_employee = current_employee
end
def create
@new_supplier = NewSupplier.new(params[:new_supplier])
@new_supplier.current_employee = current_employee
if @new_supplier.save
sign_in @new_supplier.employee unless current_employee
session[:supplier_id] = @new_supplier.supplier.try(:id)
redirect_to supplier_root_path(anchor: '/pages/introduction')
else
render 'new'
end
end
end