Class: HelpController

Inherits:
ApplicationController show all
Defined in:
app/controllers/help_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#check_lang, #prepare_attached_docs_request

Instance Method Details

#i18nObject

[View source]

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/help_controller.rb', line 10

def i18n
  lang=I18n.locale
  filepath="#{Rails.root}/config/locales/sb.#{lang}.yml"
  if params[:cat] && params[:field]
    result = YAML.load_file(filepath)["#{lang}"]["sb"][params[:cat]][params[:field]]
    if result 
      conf = { "result": result}
    else
      conf = { "result": "undefined"}
    end
  else
    if params[:cat]
      conf = YAML.load_file(filepath)["#{lang}"]["sb"][params[:cat]]
    elsif params[:field]
      result = YAML.load_file(filepath)["#{lang}"]["sb"][params[:field]]
      if result 
        conf = { "result": result}
      else
        conf = { "result": "undefined"}
      end
    else
      conf = YAML.load_file(filepath)["#{lang}"]["sb"]
    end
  end
  render json: conf
end

#indexObject

before_action :authenticate_user!

[View source]

4
5
6
7
8
# File 'app/controllers/help_controller.rb', line 4

def index
  unless current_user.is_admin?
    redirect_to root_url
  end
end