Created
July 19, 2010 07:17
-
-
Save jschementi/481096 to your computer and use it in GitHub Desktop.
Blog: MIX 10 Part 2.1
This file contains hidden or 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
get('/') { | |
"Hello, World" | |
} |
This file contains hidden or 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
get '/' do | |
"Hello, World" | |
end |
This file contains hidden or 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
def index(req, rsp): | |
rsp.write("Hello, World") | |
get('/')(index) |
This file contains hidden or 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
def verbose() | |
return "Verbose, World" | |
end | |
get('/', method('verbose')) |
This file contains hidden or 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
@sinatra.get('/') | |
def index(req, rsp): | |
rsp.write("Hello, World") |
This file contains hidden or 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
%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), "%") |
This file contains hidden or 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 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 |
This file contains hidden or 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
get '/' do | |
haml :index, :locals => { | |
:stats => Stats.get_latest | |
} | |
end |
This file contains hidden or 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
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