Sha256: ced8af653a3ad6ded05a8d950a9abb25ffed8a88700ad08b015e3e8ccf4e278f
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
# Ramaze version of the merb tutorial # http://www.socialface.com/slapp/ require 'rubygems' require 'ramaze' require 'sequel' DB = Sequel.sqlite :logger => Ramaze::Log class Post < Sequel::Model set_schema{ primary_key :id; time :created_at; text :text } before_create{ self.created_at ||= Time.now } create_table end %w[Ramaze Rocks].abbrev.keys.sort.each{|text| Post.create(:text => text) } class MainController < Ramaze::Controller def index @posts = Post.order(:created_at.DESC).first(10) %q(<h1>Welcome to Rapp</h1> <h2>A minimal chat wall</h2> <p>Recent Posts:</p> <div id="posts" class="container"> <?r @posts.each do |post| ?> <div id="post-#{post.id}" class="post"> <p class="text">#{post.text}</p> <p class="created">#{post.created_at}</p> </div> <?r end ?> </div> <p>Post Something:</p> <form action="#{Rs(:create)}" method="POST"> <input type="text" size="40" name="text" /> <input type="submit" value="Post Message!" /> </form>) end def create Post.create(:text => request[:text]) redirect Rs(:/) end end Ramaze.start
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clivecrous-ramaze-0.3.9.5 | examples/rapp.rb |