Class: Wafflemix::PagesController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#menu_items

Instance Method Details

#homeObject



26
27
28
29
30
31
32
# File 'app/controllers/wafflemix/pages_controller.rb', line 26

def home
  @page = Page.find_by_link_url('home')

  respond_to do |format|
    format.html
  end
end

#indexObject



6
7
8
9
10
11
12
# File 'app/controllers/wafflemix/pages_controller.rb', line 6

def index
  @pages = Page.active.arrange(:order => :position)
  
  respond_to do |format|
    format.html
  end
end

#mercury_updateObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/wafflemix/pages_controller.rb', line 34

def mercury_update
  if params[:id]
    page = Page.find(params[:id])
  else
    page = Page.find_by_link_url(params[:path].to_s.split('/').last)#(params[:path] ? params[:path].to_s.split('/').last : params[:id])
  end

  page.title = params[:content][:page_title][:value] if params[:content][:page_title]

  params[:content].each do |key, value|
    if key =~ /content_section/
      section = key.gsub /(content_section_|_)/, 'content_section_' => '', '_' => ''
      content_to_update = page.content_parts.find_by_name(section)
      content_to_update.content = value[:value]
      content_to_update.save
    end
  end
  page.save!
  render text: ""
end

#showObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/wafflemix/pages_controller.rb', line 14

def show
  if params[:id]
    @page = Page.find(params[:id])
  else
    @page = Page.find_by_link_url(params[:path].to_s.split('/').last)#(params[:path] ? params[:path].to_s.split('/').last : params[:id])
  end

  respond_to do |format|
    format.html
  end
end