class Posts < Merb::Controller def new #session[:foo] = 'bar' render end def create @post = Post.create( :title => params[:title], :body => params[:body]) redirect "/posts/show/#{@post.id}" end def show #puts session[:foo] @post = Post.find params[:id] @comments = @post.comments render end def list @posts = Post.find :all, :limit => 4 render end def add_comment puts params.inspect @post = Post.find params[:post_id] @post.comments.create :name => params[:comment_name], :body => params[:comment_body] @comments = @post.comments.reload render_js 'comment' end def delete_comment @post = Post.find params[:post_id] @post.comments.destroy params[:id] @comments = @post.comments.reload render_js 'comment' end def index list end end