Created
February 24, 2013 18:13
-
-
Save paulca/5024888 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 Router | |
extend Just::Router | |
resources :posts | |
end | |
class Post | |
include Just::Model | |
end | |
class PostsController | |
include Just::Controller | |
def index | |
Post::Views::Index.new.to_html | |
end | |
def new | |
Post::Views::New.new.to_html | |
end | |
def create | |
view = Post::Views::Create.new(params[:post]) | |
if view.success? | |
view.to_html | |
else | |
redirect_to :new | |
end | |
end | |
end | |
class Post::Views::Index | |
def posts | |
Post.all | |
end | |
def to_html | |
ERB.new("<%- posts.each do |post| -%><%= post.title %><%- end -%>") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment