Class: WorkUnitsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- WorkUnitsController
- Defined in:
- app/controllers/work_units_controller.rb
Instance Method Summary collapse
- #create_in_dashboard ⇒ Object
- #create_in_ticket ⇒ Object
- #edit ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods included from ControllerMixins::WorkUnits
Instance Method Details
#create_in_dashboard ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/work_units_controller.rb', line 16 def create_in_dashboard if request.xhr? if @work_unit.save suspended = @work_unit.client.status == "Suspended" if suspended render :json => {success: true, notice: "This client is suspended. Please contact an Administrator."}, :layout => false, :status => 200 and return else render :json => {success: true}, :layout => false, :status => 200 and return end else render :json => @work_unit.errors..to_json, :layout => false, :status => 406 and return flash[:error] = t(:work_unit_created_unsuccessfully) end end end |
#create_in_ticket ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/work_units_controller.rb', line 34 def create_in_ticket @work_unit = WorkUnit.new(params[:work_unit]) @work_unit.user = current_user if @work_unit.save flash[:notice] = "Work Unit created successfully" redirect_to ticket_path(@work_unit.ticket) else flash[:error] = "There was a problem creating the work unit." render 'work_units/new' end end |
#edit ⇒ Object
49 50 |
# File 'app/controllers/work_units_controller.rb', line 49 def edit end |
#new ⇒ Object
13 14 |
# File 'app/controllers/work_units_controller.rb', line 13 def new end |
#show ⇒ Object
46 47 |
# File 'app/controllers/work_units_controller.rb', line 46 def show end |
#update ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/work_units_controller.rb', line 52 def update if @work_unit.update_attributes(params[:work_unit]) flash[:notice] = t(:work_unit_updated_successfully) redirect_to @work_unit else flash.now[:error] = t(:work_unit_updated_unsuccessfully) redirect_to edit_work_unit_path end end |