class WebsiteController < ApplicationController def index redirect_to :action => :list end def list @websites = Website.find(:all, :conditions => ["is_approved = 1"]) end def show @website = Website.find_by_id(params[:id], :conditions => ["is_approved = 1"]) return redirect_to :action => :list if @website.nil? @next_website = @website.next() @prev_website = @website.prev() @comments = @website.comments.find(:all) @ratings = @website.rating end def create if request.post? @website = Website.create(params[:website]) if @website.save redirect_to :action => :show, :id => @website[:id] end notice = [] @website.errors.each {|k, error| notice << [error] } @flash[:notice] = notice.join("
") redirect_to :action => :list end end endr