[Ruby] Using ActiveRecord outside Rails
Jeffrey Hulten
jhulten at gmail.com
Mon Oct 2 23:22:21 PDT 2006
Turning off the warnings unmasked the real problem, an issue with access to
the correct ports from my home office. Thanks!
So, note to self. ActiveRecord warnings are mostly useless and may mask the
real problem.
On 10/2/06, Ryan Davis <ryand-ruby at zenspider.com> wrote:
>
>
> On Oct 2, 2006, at 4:16 PM, Jeffrey Hulten wrote:
>
> > So I am trying to use ActiveRecord in a series of Rake tasks for
> > work and I
> > am running into some issues. When I run my script I get the
> > warnings below
> > and then the script hangs. It is hanging on a simple find(1). Any
> > help
> > would be appreciated.
>
> First off, turn off the warnings. Rails sucks in that regard hands
> down. Second, please use a mailer that doesn't butcher your code
> pastes. Third, cut the unrelated crap out of your email so we can
> focus on the problem at hand. We haven't been working with this code
> as long as you have been.
>
> > sulla:~/Projects/ASD/INF_0609R2 jeffh$ rake test:models
> > (in /Users/jeffh/Projects/ASD/INF_0609R2)
> > /usr/bin/ruby -w
> > [snip]
> > The model:
> >
> > require 'ar_connection'
> > class Program < ActiveRecord::Base
> >
> > has_many :branches
> >
> > belongs_to :program_manager,
> > :class_name => 'Person',
> > :foreign_key => 'pm_id'
> > end
> >
> >
> > The connection file:
> >
> > require 'rubygems'
> > require 'active_record'
> >
> > conn = ActiveRecord::Base.establish_connection(
> > :adapter => 'mysql',
> > :host => 'host.company.com',
> > :port => 3307,
> > :database => 'tools_dev',
> > :username => 'ME',
> > :password => 'MINE'
> > )
> >
> > The model test:
> >
> > require 'test/unit'
> > require 'program'
> >
> > class TestModelPrograms < Test::Unit::TestCase
> >
> > def test_find
> > program = Program.find(1)
> > assert_equal('MAINT', program.short_name)
> > end
> > end
>
> The rest of this looks fine, once chopped up... what does the dev log
> show?
>
> _______________________________________________
> Ruby at zenspider.com
> http://www.zenspider.com/seattle.rb
> http://www.zenspider.com/mailman/listinfo/ruby
>
--
Jeffrey Hulten
jhulten at gmail.com
More information about the Ruby
mailing list