All pastes #34267 Raw Edit

RaydenUni

public ruby v1 · immutable
#34267 ·published 2005-12-19 22:47 UTC
rendered paste body
class FlatPagesController < ApplicationController  def index    list    render :action => 'list'  end  def list    @flat_page_pages, @flat_pages = paginate :flat_pages, :per_page => 10  end  def show    @flat_page = FlatPage.find(params[:id])  end  def new    @flat_page = FlatPage.new  end  def create    @flat_page = FlatPage.new(params[:flat_page])    if @flat_page.save      flash[:notice] = 'FlatPage was successfully created.'              @org_relation = OrgRelation.new(params[:org_relation])        @org_relation.save #calls org_relation to create an entry.            redirect_to :action => 'list'    else      render :action => 'new'    end  end  def edit    @flat_page = FlatPage.find(params[:id])  end  def update    @flat_page = FlatPage.find(params[:id])    if @flat_page.update_attributes(params[:flat_page])      flash[:notice] = 'FlatPage was successfully updated.'      redirect_to :action => 'show', :id => @flat_page    else      render :action => 'edit'    end  end  def destroy    FlatPage.find(params[:id]).destroy    redirect_to :action => 'list'  endend