Class: Backend::JanusesController

Inherits:
BaseController show all
Defined in:
app/controllers/backend/januses_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

#toggleObject

Saves the state of the kujakus


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/backend/januses_controller.rb', line 22

def toggle
  face = params[:face].to_s
  janus = params[:id].to_s.strip
  if janus.blank?
    head :not_found
  else
    default = params[:default] || 'list'
    preference_name = "interface.janus.#{janus}.current_face"
    preference = current_user.preferences.find_by(name: preference_name)
    if face != default || (preference && face != preference.value.to_s)
      p = current_user.preference(preference_name, default)
      p.set!(face)
    end
    head :ok
  end
end