Class: Refinery::Admin::PagesController

Inherits:
Refinery::AdminController show all
Defined in:
pages/app/controllers/refinery/admin/pages_controller.rb

Instance Method Summary collapse

Methods included from BaseController

#admin?, included, #refinery_admin_root_path, #searching?

Methods included from Refinery::ApplicationController

#admin?, #current_refinery_user, #error_404, #from_dialog?, #home_page?, included, #local_request?

Instance Method Details

#childrenObject



19
20
21
22
# File 'pages/app/controllers/refinery/admin/pages_controller.rb', line 19

def children
  @page = find_page
  render :layout => false
end

#newObject



12
13
14
15
16
17
# File 'pages/app/controllers/refinery/admin/pages_controller.rb', line 12

def new
  @page = Page.new(new_page_params)
  Pages.default_parts_for(@page).each_with_index do |page_part, index|
    @page.parts << PagePart.new(:title => page_part[:title], :slug => page_part[:slug], :position => index)
  end
end

#updateObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'pages/app/controllers/refinery/admin/pages_controller.rb', line 24

def update
  if @page.update_attributes(page_params)
    flash.notice = t('refinery.crudify.updated', what: "'#{@page.title}'")

    if from_dialog?
      self.index
      @dialog_successful = true
      render :index
    else
      if params[:continue_editing] =~ /true|on|1/
        if request.xhr?
          render partial: 'save_and_continue_callback',
                 locals: save_and_continue_locals(@page)
        else
          redirect_to :back
        end
      else
        redirect_back_or_default(refinery.admin_pages_path)
      end
    end
  else
    if request.xhr?
      render :partial => '/refinery/admin/error_messages', :locals => {
        :object => @page,
        :include_object_name => true
      }
    else
      render 'edit'
    end
  end
end