Skip to content

Instantly share code, notes, and snippets.

@mbijon
Forked from carlopecchia/Friendly ORM sample
Created September 28, 2016 17:21
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 mbijon/88f2946c553aaad39ca74782eef41e4b to your computer and use it in GitHub Desktop.
Save mbijon/88f2946c553aaad39ca74782eef41e4b to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'friendly'
Friendly.configure(
:adapter => 'mysql',
:host => 'localhost',
:user => 'root',
:password => '',
:database => 'friendly_db'
)
class FreeTweet
include Friendly::Document
attribute :author, String
attribute :content, String
indexes :author
end
Friendly.create_tables!
[
["foo", "Me"],
["bar", "Me"],
["something really smart(er) than foo, bar, baz, ...", "Homer Simpson"]
].each do |content, author|
FreeTweet.create(:author => author, :content => content)
end
FreeTweet.all(:author => 'Me').each do |t|
puts "#{t.content} - by #{t.author}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment