🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.ruby
2 messages
2 total messages Started by Jaroslaw Zabiello Fri, 27 Oct 2006 14:12
Active Record i problem z prostą relacją
#260
Author: Jaroslaw Zabiello
Date: Fri, 27 Oct 2006 14:12
33 lines
1515 bytes
Mam 2 modele

class DestinationDescription
...
has_many :destinations, 
         :class_name => 'Destination',
         :foreign_key =>'Destination_ID'
              
i

class Destination
...
belongs_to :destination_descriptions, 
           :class_name => 'DestinationDescription', 
           :foreign_key=> 'Destination_ID'     

Sprawdzam z konsoli:

>> dd = DestinationDescription.find :first
>> dd.Destination_ID # => 93
>> d = Destination.find :first, :conditions => 'Destination_ID=93'
>> d.Destination_ID # => 93

Czyli dane w tabeli maja sens. A teraz najgorsze:

>> dd.destinations # => []
>> dd.destinations_count # => 0 ZERO!!!

Co tu jest nie tak? Dlaczego nie ma danych?

-- 
Jarosław Zabiełło
http://blog.zabiello.com
Re: Active Record i problem z prosta relacja
#261
Author: simon
Date: Sat, 28 Oct 2006 10:33
37 lines
2154 bytes
Jaroslaw Zabiello napisal(a):
> Mam 2 modele
>
> class DestinationDescription
> ...
> has_many :destinations,
>          :class_name => 'Destination',
>          :foreign_key =>'Destination_ID'
>
> i
>
> class Destination
> ...
> belongs_to :destination_descriptions,
>            :class_name => 'DestinationDescription',
>            :foreign_key=> 'Destination_ID'
>
> Sprawdzam z konsoli:
>
> >> dd = DestinationDescription.find :first
> >> dd.Destination_ID # => 93
> >> d = Destination.find :first, :conditions => 'Destination_ID=93'
> >> d.Destination_ID # => 93
>
> Czyli dane w tabeli maja sens. A teraz najgorsze:
>
> >> dd.destinations # => []
> >> dd.destinations_count # => 0 ZERO!!!
>
> Co tu jest nie tak? Dlaczego nie ma danych?
>

Podeslij dumpy z w/w tabel, bo inaczej to ciezko powiedziec co moze byc
nie tak (rozumiem ze obie klasy dziedzicza z ActiveRecord::Base tylko
nie zaciemniales opisu).

Szymon
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads