Poseidon is a very simple example rack application that help you to understand how to build your own rack applications with middlewares based MVC pattern and Active record
rake db:new_migration name=Posts
class Posts < ActiveRecord::Migration
def up
create_table :posts do |t|
t.string :title
t.string :body
t.timestamps
end
end
models/post.rb
class Post < ActiveRecord::Base
end
controllers/post_controller.rb
class PostController < ApplicationController
def index
@posts = Post.all
end
end
view/post/show.rb
<% @posts.each do |p| %>
<li><%= p.title %></li>
<% end %>
rake db:setup
./console.sh
###Create a post
Post.create title: "works?"
{
:id => 1,
:title => "works?",
:body => nil,
:created_at => 2013-12-12 15:32:26 UTC,
:updated_at => 2013-12-12 15:32:26 UTC
}
rackup
localhost:8080/post/
localhost:8080/post/new