L
Louis J Scoras
------=_Part_2238_12142549.1128001801583
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Hi all;
I'm trying to use active record to populate a database for querying account
information on a bunch of Unix machines.
Whenever the ":belongs_to users" association is declared in the following
code, it seems to execute the script twice--that is it prints the 10 twice.
If I remove the commented line, than it works correctly and only prints
once. Other than that, the relationships seem to be working correctly.
I'm wondering if this has something to do with how I'm accessing the librar=
y
(no gems), from the location ubuntu installed the package to. Or, am I doin=
g
something else completely wrong?
$:.unshift '/usr/share/rails/activerecord/lib'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter =3D> "mysql",
:host =3D> "localhost",
:username =3D> "scora002",
:database =3D> "accounts"
)
class User < ActiveRecord::Base
has_many :accounts
end
class Account < ActiveRecord::Base
belongs_to :host
belongs_to :user # This line seems to be
belongs_to rimary_group, # a problem.
:class_name =3D> "Group",
:foreign_key =3D> "primary_group_id"
has_and_belongs_to_many :groups
end
puts 10
Thanks!
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Hi all;
I'm trying to use active record to populate a database for querying account
information on a bunch of Unix machines.
Whenever the ":belongs_to users" association is declared in the following
code, it seems to execute the script twice--that is it prints the 10 twice.
If I remove the commented line, than it works correctly and only prints
once. Other than that, the relationships seem to be working correctly.
I'm wondering if this has something to do with how I'm accessing the librar=
y
(no gems), from the location ubuntu installed the package to. Or, am I doin=
g
something else completely wrong?
$:.unshift '/usr/share/rails/activerecord/lib'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter =3D> "mysql",
:host =3D> "localhost",
:username =3D> "scora002",
:database =3D> "accounts"
)
class User < ActiveRecord::Base
has_many :accounts
end
class Account < ActiveRecord::Base
belongs_to :host
belongs_to :user # This line seems to be
belongs_to rimary_group, # a problem.
:class_name =3D> "Group",
:foreign_key =3D> "primary_group_id"
has_and_belongs_to_many :groups
end
puts 10
Thanks!