Class: Backend::CapIsletsController

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

Instance Attribute Summary

Attributes inherited from ApplicationController

#current_theme

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseController

account_lettering_states_crit, accounts_range_crit, amount_range_crit, crit_params, journal_entries_states_crit, journal_letter_crit, journal_period_crit, journals_crit, search_conditions

Methods inherited from ApplicationController

#after_sign_in_path_for, #authorized?, human_action_name, #human_action_name, #session_controller?

Class Method Details

.cap_islets_conditionsObject

params:

:q Text search
:state State search
:current_campaign

29
30
31
32
33
34
35
36
37
# File 'app/controllers/backend/cap_islets_controller.rb', line 29

def self.cap_islets_conditions
  code = ''
  code = search_conditions(cap_islets: [:islet_number]) + " ||= []\n"
  code << "if current_campaign\n"
  code << "  c[0] << \" AND #{CapStatement.table_name}.campaign_id IN (?)\"\n"
  code << "  c << current_campaign.id\n"
  code << "end\n"
  code.c
end

Instance Method Details

#convertObject


52
53
54
55
56
57
58
59
60
# File 'app/controllers/backend/cap_islets_controller.rb', line 52

def convert
  return unless @cap_islet = find_and_check
  if params[:to] == 'cultivable_zone'
    cultivable_zone = CultivableZone.create!(name: @cap_islet.campaign_name + '-' + @cap_islet.islet_number, shape: @cap_islet.shape)
    redirect_to params[:redirect] || { controller: :cultivable_zones, action: :show, id: cultivable_zone.id }
  else
    redirect_to backend_cap_islet(@cap_islet)
  end
end