Thursday, October 28, 2010

[Rails] [solved] Re: Using ActiveRecord 3.0.x with Ruby 1.9.2

Assuming there is a table named "posts", this code will work:

require 'rubygems'
gem 'activerecord', '3.0.1'
require 'active_record'

ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => "/users/dwormuth/sites/rails/testrails/db/
development.sqlite3"
)

class Post < ActiveRecord::Base
end

post = Post.find(1)
puts post.name
puts "It worked"

On Oct 27, 8:37 pm, dwormuth <dworm...@post.harvard.edu> wrote:
> I tried this too, but when I put it in an .rb file, I get the error
> above.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate