Can someone remind me of the incantation to use ActiveRecord in a
plain ruby program for the versions specified. I’m not having any luck
searching with google and I keep getting:
`require’: no such file to load – activerecord (LoadError)
Not sure if this is a dependency or file path problem.
Thanks
require ‘active_record’ ?
Can someone remind me of the incantation to use ActiveRecord in a
plain ruby program for the versions specified. I’m not having any luck
searching with google and I keep getting:
`require’: no such file to load – activerecord (LoadError)
have you tried:
require ‘rubygems’
require ‘active_record’
D:>irb
irb(main):001:0> require ‘rubygems’
=> true
irb(main):002:0> require ‘active_record’
=> true
irb(main):003:0> exit
D:>rails -v
Rails 3.0.1
I tried this too, but when I put it in an .rb file, I get the error
above.
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”