Created
March 23, 2010 11:51
-
-
Save botanicus/341086 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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