Class: ApplicationController
  
  
  
  
  
    - Inherits:
- 
      ActionController::Base
      
        
          - Object
- ActionController::Base
- ApplicationController
 show all
    - Defined in:
- lib/generators/dummy/templates/controllers/application_controller.rb
 
Defined Under Namespace
  
    
  
    
      Classes: PageNotFound
    
  
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
    Instance Method Details
    
      
  
  
    #available_roots  ⇒ Object 
  
  
  
  
    | 
58
59
60 | # File 'lib/generators/dummy/templates/controllers/application_controller.rb', line 58
def available_roots
  @roots ||= node_class.roots.where(locale: I18n.available_locales, active: true)
end | 
 
    
      
  
  
    #node_class  ⇒ Object 
  
  
  
  
    | 
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 | # File 'lib/generators/dummy/templates/controllers/application_controller.rb', line 34
def node_class
  if @node_class.blank?
        routing = Releaf::Content.routing
    if routing.length == 1
                  node_class = routing.keys.first.constantize
    else
                  node_class = Releaf::Content.routing.find { |node_class_name, options| request.host =~ options[:constraints][:host] }.first.constantize
    end
    @node_class = node_class
  end
  @node_class
end | 
 
    
      
  
  
    #redirect_to_locale_root  ⇒ Object 
  
  
  
  
    | 
19
20
21
22
23
24
25
26
27
28 | # File 'lib/generators/dummy/templates/controllers/application_controller.rb', line 19
def redirect_to_locale_root
      target_root = available_roots.first
  if target_root
    redirect_to target_root.path
  else
    render plain: "Welcome to Releaf", layout: true
  end
end | 
 
    
      
  
  
    #render_404  ⇒ Object 
  
  
  
  
    | 
11
12
13 | # File 'lib/generators/dummy/templates/controllers/application_controller.rb', line 11
def render_404
  render file: Rails.root.join('public', '404.html'), status: 404, layout: nil
end | 
 
    
      
  
  
    #set_locale  ⇒ Object 
  
  
  
  
    | 
15
16
17 | # File 'lib/generators/dummy/templates/controllers/application_controller.rb', line 15
def set_locale
  I18n.locale = params[:locale]
end | 
 
    
      
  
  
    #site  ⇒ Object 
  
  
  
  
    | 
53
54
55
56 | # File 'lib/generators/dummy/templates/controllers/application_controller.rb', line 53
def site
    @site = Releaf::Content.routing[node_class.name][:site]
end | 
 
    
      
  
  
    #translation_scope  ⇒ Object 
  
  
  
  
    | 
30
31
32 | # File 'lib/generators/dummy/templates/controllers/application_controller.rb', line 30
def translation_scope
  "public." + self.class.name.gsub("Controller", "").underscore
end |