-
-
Save alexandre-mbm/4f30d73e224e45760ecf to your computer and use it in GitHub Desktop.
Example: Friendly + Sinatra
This file contains 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
#!/usr/bin/env ruby | |
require 'json' # gem install json # also: activesupport (~> 2.3.18) | |
require 'rubygems' # gem install rubygems | |
require 'sinatra' # gem install sinatra | |
require 'friendly' # gem install ihoka-friendly | |
Friendly.configure({ | |
:adapter => "sqlite", | |
:database => "database.sqlite3" | |
}) | |
class Blob | |
include Friendly::Document | |
attribute :name, String | |
attribute :value, String | |
indexes :name | |
end | |
before do | |
Friendly.create_tables! | |
Blob.create({ | |
:name => "Mike", | |
:value => "Social Justice Hacker" | |
}) | |
end | |
get '/' do | |
Blob.first(:name => "Mike").inspect | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment