Skip to content

Instantly share code, notes, and snippets.

@botanicus
Created March 23, 2010 11:51
Show Gist options
  • Save botanicus/341086 to your computer and use it in GitHub Desktop.
Save botanicus/341086 to your computer and use it in GitHub Desktop.
class Posts < RESTController
object_name :post
template_root "blog/posts"
named_route :post
def index(page)
super do
Post.paginate(page, 20)
end
end
def show(id)
super { Post.get(id) }
end
def new
super { Post.new }
end
def edit(id)
super { @post || Post.get(id) }
end
def create(post)
notice = "Post create successfuly"
error = "Saving failed"
super(notice, error) do
@post = Post.new(post)
end
end
def update(id, post)
super do
@post = Post.attributes.merge!(post)
end
end
end
class MyCustomizedPosts < Posts
def create(post)
super(post)
rescue Rango::Exceptions::Redirection
redirect "/"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment