🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.ruby
Article #260

Active Record i problem z prostą relacją

#260
From: 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
Technical Details
Message-ID: <163ry7by917p9.wcavm579lwnu$.dlg@40tude.net>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail
From: Jaroslaw Zabiello <hipertracker@gmail.com>
Newsgroups: pl.comp.lang.ruby
Subject: Active Record i problem z prostą relacją
Date: Fri, 27 Oct 2006 15:12:29 +0100
Organization: "Portal Gazeta.pl -> http://www.gazeta.pl"
Lines: 33
Message-ID: <163ry7by917p9.wcavm579lwnu$.dlg@40tude.net>
NNTP-Posting-Host: 213.190.141.10
Mime-Version: 1.0
X-Trace: inews.gazeta.pl 1161958409 6954 213.190.141.10 (27 Oct 2006 14:13:29 GMT)
X-Complaints-To: usenet@agora.pl
NNTP-Posting-Date: Fri, 27 Oct 2006 14:13:29 +0000 (UTC)
X-User: newsgate2006
User-Agent: 40tude_Dialog/2.0.15.1pl
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit