Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
class Posts < Application # merb controller provide :html by default # when you see render @post merb will look # for a template foo.html.erb or foo<contenttype>.erb # based on the accept header and serve that directly. If there # is not template for that content type then merb will call # to_json, to_xml or to_yaml on the passed in object based # on the accept header or format. provides :xml, :js, :yaml def index @posts = Post.find(:all) render @posts end def show(id) @post = Post.find(id) render @post end def new(post) only_provides :html @post = Post.new(post) render end def create(post) @post = Post.new(post) if @post.save redirect url(:post, @post) else render :action => :new end end def edit(id) only_provides :html @post = Post.find(id) render end def update(id, post) @post = Post.find(id) if @post.update_attributes(post) redirect url(:post, @post) else raise BadRequest end end def destroy(id) @post = Post.find(id) if @post.destroy redirect url(:posts) else raise BadRequest end end end
This paste will be private.
From the Design Piracy series on my blog: