class NewsController < ApplicationController layout "greymarket" def index @posts = Post.recent(10) end def show @post = Post.find(params[:id]) end def comment @post = Post.find(params[:id]) @comment = Comment.new(params[:comment]) @post.comments << @comment if @post.save flash[:notice] = "Comment saved successfully" else flash[:notice] = "There were #{@comment.errors.count} errors when saving the comment." end render :action => "show", :id => @post.id end end