Skip to content

Instantly share code, notes, and snippets.

@paulca
Created February 24, 2013 18:13
Show Gist options
  • Save paulca/5024888 to your computer and use it in GitHub Desktop.
Save paulca/5024888 to your computer and use it in GitHub Desktop.
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