Class: Backend::CrumbsController

Inherits:
BaseController show all
Defined in:
app/controllers/backend/crumbs_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#current_theme

Instance Method Summary collapse

Methods inherited from BaseController

accounts_range_crit, crit_params, journal_entries_states_crit, journal_period_crit, journals_crit, search_conditions

Methods inherited from ApplicationController

#after_sign_in_path_for, #authorized?, human_action_name, #human_action_name

Instance Method Details

#convertObject

Creates an intervention from crumb and redirects to an edit form for the newly created intervention.


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/backend/crumbs_controller.rb', line 33

def convert
  return unless crumb = find_and_check
  intervention_path = crumb.intervention_path
  begin
    if intervention = intervention_path.convert!(params.slice(:procedure_name, :working_width))
      redirect_to edit_backend_intervention_path(intervention)
    elsif current_user.unconverted_crumb_days.any?
      redirect_to backend_crumbs_path(worked_on: params[:worked_on])
    else
      redirect_to backend_interventions_path
    end
  rescue StandardError => e
    notify_error(e.message)
    redirect_to backend_crumbs_path(worked_on: params[:worked_on])
  end
end

#indexObject


23
24
25
26
27
28
29
# File 'app/controllers/backend/crumbs_controller.rb', line 23

def index
  @worked_on = if params[:worked_on].blank?
                 current_user.unconverted_crumb_days.first
               else
                 params[:worked_on].to_date
               end
end