Class: Spreadhead::PagesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/spreadhead/pages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/spreadhead/pages_controller.rb', line 22

def create
  @page = ::Page.new(params[:page])
  respond_to do |format|
    if @page.save
      format.html { redirect_to pages_url }
      format.xml  { head :created, :location => pages_url }
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @page.errors.to_xml }
    end
  end
end

#destroyObject



48
49
50
51
52
53
54
55
# File 'app/controllers/spreadhead/pages_controller.rb', line 48

def destroy
  @page = ::Page.find(params[:id])
  @page.destroy
  respond_to do |format|
    format.html { redirect_to pages_url }
    format.xml  { head :ok }
  end
end

#editObject



18
19
20
# File 'app/controllers/spreadhead/pages_controller.rb', line 18

def edit
  @page = ::Page.find(params[:id])
end

#indexObject



10
11
12
# File 'app/controllers/spreadhead/pages_controller.rb', line 10

def index 
  @pages = ::Page.find(:all)
end

#newObject



6
7
8
# File 'app/controllers/spreadhead/pages_controller.rb', line 6

def new
  @page = ::Page.new    
end

#showObject



14
15
16
# File 'app/controllers/spreadhead/pages_controller.rb', line 14

def show
  @page = ::Page.published.find_by_url!(params[:url].to_a.join('/'))  
end

#updateObject



35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/spreadhead/pages_controller.rb', line 35

def update
  @page = ::Page.find(params[:id])
  respond_to do |format|
    if @page.update_attributes(params[:page])
      format.html { redirect_to pages_url }
      format.xml  { head :ok }
    else
      format.html { render :action => "edit" }
      format.xml  { render :xml => @page.errors.to_xml }
    end
  end
end