Class: RubberRing::RubberRingController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/rubber_ring/rubber_ring_controller.rb

Direct Known Subclasses

AttachmentsController, CmsController

Instance Method Summary collapse

Instance Method Details

#buildObject



20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/rubber_ring/rubber_ring_controller.rb', line 20

def build
  # when running with puma and multiple workers this is the best option
  Build.run!(request)

  # when running with single process server, new thread needs to be spawn
  # downside of this option is, that we can not know when build is completed

  #Thread::new{
  #  Build.run!(request)
  #}
end

#load_page_contentObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/rubber_ring/rubber_ring_controller.rb', line 8

def load_page_content
  page = Page.where(
    controller: params[:controller],
    action:     params[:action],
    locale:     params[:locale] || I18n.default_locale.to_s
  )

  @page = page.empty? ? Page.new : page.first
  @page.edit_mode = true
  @images, @attachments = Util.load_attachments_page(params)
end

#publishObject



32
33
34
35
36
37
38
39
40
# File 'app/controllers/rubber_ring/rubber_ring_controller.rb', line 32

def publish
  begin
    Publish.assets!
  rescue Errno::EACCES
    flash.now[:error] =
      'Rubber Ring is trying to copy files on to path which is not writable.
       Please tell developers to check publish.yml file.'
  end
end

#respond(page) ⇒ Object



47
48
49
# File 'app/controllers/rubber_ring/rubber_ring_controller.rb', line 47

def respond(page)
  render :json => {controller: page.controller, action: page.action, content: page.content}
end

#set_localeObject



42
43
44
45
# File 'app/controllers/rubber_ring/rubber_ring_controller.rb', line 42

def set_locale
  I18n.locale = params[:locale] || I18n.default_locale
  @locale = I18n.locale.to_s
end