From 6b2883d2609e79fc6dde2ebf3ebd2622edb81070 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 11 Nov 2007 06:19:15 +0000 Subject: [PATCH] cleanup git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@16 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7 --- app/controllers/pages_controller.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 3d8c34b..d14b0c7 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,19 +1,18 @@ class PagesController < ApplicationController append_before_filter :fetch_page, :only => [ :show, :edit, :update, :destroy ] - + # GET /pages # GET /pages.xml def index @page = Page.find_by_title 'HomePage' @page ||= Page.create :title => 'HomePage', :redcloth => 'Welcome to BarleySodas!' - respond_to do |format| format.html # index.rhtml format.xml { render :xml => @page.to_xml } end end - + # GET /pages/1 # GET /pages/1.xml def show @@ -22,16 +21,16 @@ class PagesController < ApplicationController format.xml { render :xml => @page.to_xml } end end - + # GET /pages/new def new @page = Page.new end - + # GET /pages/1;edit def edit end - + # POST /pages # POST /pages.xml def create @@ -39,22 +38,23 @@ class PagesController < ApplicationController respond_to do |format| if @page.save flash[:notice] = 'Page was successfully created.' - format.html { redirect_to page_url(@page) } - format.xml { head :created, :location => page_url(@page) } + format.html { redirect_to page_url({ :id => @page.title_for_url }) } + format.xml { head :created, + :location => page_url({ :id => @page.title_for_url }) } else format.html { render :action => "new" } format.xml { render :xml => @page.errors.to_xml } end end end - + # PUT /pages/1 # PUT /pages/1.xml def update respond_to do |format| if @page.update_attributes(params[:page]) flash[:notice] = 'Page was successfully updated.' - format.html { redirect_to page_url(@page) } + format.html { redirect_to page_url({ :id => @page.title_for_url }) } format.xml { head :ok } else format.html { render :action => "edit" } @@ -62,7 +62,7 @@ class PagesController < ApplicationController end end end - + # DELETE /pages/1 # DELETE /pages/1.xml def destroy @@ -73,16 +73,16 @@ class PagesController < ApplicationController format.xml { head :ok } end end - + ## # Redirects the user to a default location. # def default_action redirect_to(pages_path) end - + protected - + def fetch_page @page = Page.find_by_title(Page.title_from_url(params[:id])) end