[Nitro] HasManyCollection#each
itsme213
itsme213 at hotmail.com
Sun Nov 27 13:15:34 EST 2005
I tried #<< to add objects to the relation.
#each still does not work for me.
Thanks.
-----------------
require 'og'
class A
property :name, String
belongs_to A
def initialize(n)
@name = n
end
end
class B
property :name, String
has_many :posts, A
end
Og.setup(
:store => :sqlite
)
b = B.new
a1 = A.new "a1"
a2 = A.new "a2"
b.posts << a1
b.posts << a2
b.save
a1.save
a2.save
puts b.posts.count #=> 0
b.posts.each {|a| puts a.name} #=> nothing
----- Original Message -----
From: "George Moschovitis" <george.moschovitis at gmail.com>
To: "General discussion about Nitro" <nitro-general at rubyforge.org>
Sent: Sunday, November 27, 2005 4:47 AM
Subject: Re: [Nitro] HasManyCollection#each
>> > Given:
>> >
>> > class A
>> > property :name, String
>> > def initialize n
>> > @name = n
>> > end
>> > end
>> >
>> > class B
>> > property :name, String
>> > has_many :as, A
>> > end
>> >
>> > b = B.new
>> > b.add_a(A.new "a1")
>> > b.add_a(A.new "a2")
>
> Try:
>
> b.as << A.new('a1')
>
> btw
> has_many :as
> has_many A
> has_many :as, A
>
> are equivalent...
>
> have a look at the Og test cases for the latest Og api...
>
> -g.
>
>
>
> --
> http://www.gmosx.com
> http://www.navel.gr
> http://www.nitrohq.com
>
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general
>
More information about the Nitro-general
mailing list