🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: belongs_to do unique key

#1140
From: Zbyszek Malec
Date: Tue, 17 Feb 2009 18:25
31 lines
1562 bytes
Dnia Tue, 26 Aug 2008 21:58:38 +0200, FOX napisał(a):

> class Currency < ActiveRecord::Base
>    has_many :exchange
> end
> 
> class Exchange < ActiveRecord::Base
>    belongs_to :currency,  :foreign_key => ...........
>        :conditions => '"exchanges".currency = "currencies".curency'
> end
> 
> 
> i tutaj w miejsce kropek przydałoby się jakieś
> wyłączenie domyślnego zachowania foreign_key

Nie mam jakiegoś większego doświadczenia z ActiveRecord, więc jak bym
głupoty pisał, to liczę że mnie ktoś poprawi.

class Currency < ActiveRecord::Base
	has_many :exchange, :primary_key => 'currency', :foreign_key => 'currency'
end

class Exchange < ActiveRecord::Base
	belongs_to :currency, :foreign_key => 'currency'
end

I jak?

-- 
Zbyszek Malec
gg 2756100
Technical Details
Message-ID: <1fwyahnjhhdr2$.1mvq434l0lole.dlg@40tude.net>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail
References: <g91nbj$cc7$1@atlantis.news.neostrada.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail
From: Zbyszek Malec <zbyszekto@tlen.pl>
Newsgroups: pl.comp.lang.ruby
Subject: Re: belongs_to do unique key
Date: Tue, 17 Feb 2009 19:25:52 +0100
Organization: "Portal Gazeta.pl -> http://www.gazeta.pl"
Lines: 31
Message-ID: <1fwyahnjhhdr2$.1mvq434l0lole.dlg@40tude.net>
References: <g91nbj$cc7$1@atlantis.news.neostrada.pl>
NNTP-Posting-Host: 212.76.37.218
Mime-Version: 1.0
X-Trace: inews.gazeta.pl 1234895153 13585 212.76.37.218 (17 Feb 2009 18:25:53 GMT)
X-Complaints-To: usenet@agora.pl
NNTP-Posting-Date: Tue, 17 Feb 2009 18:25:53 +0000 (UTC)
X-User: zbyszanna
User-Agent: 40tude_Dialog/2.0.15.1pl
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit