Skip to content

Instantly share code, notes, and snippets.

@jschementi
Created July 19, 2010 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jschementi/481096 to your computer and use it in GitHub Desktop.
Save jschementi/481096 to your computer and use it in GitHub Desktop.
Blog: MIX 10 Part 2.1
get('/') {
"Hello, World"
}
get '/' do
"Hello, World"
end
def index(req, rsp):
rsp.write("Hello, World")
get('/')(index)
def verbose()
return "Verbose, World"
end
get('/', method('verbose'))
@sinatra.get('/')
def index(req, rsp):
rsp.write("Hello, World")
%tr
%th total pass rate
%td{:colspan => 2}=
"#{tir = total_pass_rate(mspec[:ironruby], mspec[:ruby]) * 100}%"
%td=
"#{trb = total_pass_rate(mspec[:ruby], mspec[:ruby]) * 100}%"
%td=
green_or_red((tir - trb).round_to(2), "%")
class Post < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
end
class CreatePostsAndComments < ActiveRecord::Migration
def up
create_table :posts do |t|
t.string 'title'
t.text 'body'
end
create_table :comments do |t|
t.text 'body'
t.integer 'post_id'
end
end
def down
drop_table :posts
end
end
get '/' do
haml :index, :locals => {
:stats => Stats.get_latest
}
end
def get(uri):
def __get(func):
sinatra.register('get', uri, func)
return func
return __get
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment