Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # connect to the database
- ActiveRecord::Base.establish_connection(
- :adapter => "mysql", :database => "mydb",
- :host => "localhost", :username => "mydb_user",
- :password => "foo" )
- # create a model object
- class Contact < ActiveRecord::Base
- end
- # persist!
- Contact.create "name" => "Charles Nutter", "title" => "JRuby Developer"
- Contact.create "name" => "Thomas Enebo", "title" => "JRuby Developer"
- # query
- Contact.find(:all).each {|c| puts c.name}
- nutter = Contact.find_by_name("Charles Nutter")
- # update
- nutter.title = "Dark Overlord of the Universe"
- nutter.save
Add Comment
Please, Sign In to add comment