Message from discussion
help for ideas of instance method or controller
Received: by 10.42.211.6 with SMTP id gm6mr6880657icb.18.1352627812603;
Sun, 11 Nov 2012 01:56:52 -0800 (PST)
X-BeenThere: rubyonrails-talk@googlegroups.com
Received: by 10.42.68.146 with SMTP id x18ls12381906ici.7.gmail; Sun, 11 Nov
2012 01:56:12 -0800 (PST)
Received: by 10.50.153.230 with SMTP id vj6mr4051559igb.3.1352627772062;
Sun, 11 Nov 2012 01:56:12 -0800 (PST)
Received: by 10.50.153.230 with SMTP id vj6mr4051558igb.3.1352627772049;
Sun, 11 Nov 2012 01:56:12 -0800 (PST)
Return-Path: <clan...@googlemail.com>
Received: from mail-ob0-f179.google.com (mail-ob0-f179.google.com [209.85.214.179])
by gmr-mx.google.com with ESMTPS id ge7si419479igb.0.2012.11.11.01.56.11
(version=TLSv1/SSLv3 cipher=OTHER);
Sun, 11 Nov 2012 01:56:12 -0800 (PST)
Received-SPF: pass (google.com: domain of clan...@googlemail.com designates 209.85.214.179 as permitted sender) client-ip=209.85.214.179;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of clan...@googlemail.com designates 209.85.214.179 as permitted sender) smtp.mail=clan...@googlemail.com; dkim=pass header...@gmail.com
Received: by mail-ob0-f179.google.com with SMTP id eq6so1497526obc.24
for <rubyonrails-talk@googlegroups.com>; Sun, 11 Nov 2012 01:56:11 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:from:date:message-id:subject:to
:content-type;
bh=d4vZkxy9daX6TQY4Nn2gdPlKvjKiuYavcvr5jqAzSY4=;
b=IDm8YbaUZygXB3gZHAMyBS96I0Fud02/EX0cReLXjCmZ7m7N86bzwpN1MyKFt/FqVy
vcyMa60oy8bDDDawMwdx2ITJgKpkJcIuE0sFfxmIIHgNtaPKVaqHQfolN0NsXUZWvSua
9Fmnt8zbV9TgULnAGazpdLLKjIDVDl65QcVQIzqjPPGuEuWl8WyM7C+eTqPjOMWsDrO0
y9vk+2cV2TO5W4JE0nkewusG7BxN1R06qEUF/ZuMgH9oVlTB5oCnWgvzzeJjPyexhJEC
bQVd/GZsQZ0jIEnVBicziTaSLjcVzFxF0mP9flsq/8mSerqLTfaMVlJ7Y3i7hjz4LUI6
UrRw==
Received: by 10.182.115.34 with SMTP id jl2mr12636594obb.74.1352627771753;
Sun, 11 Nov 2012 01:56:11 -0800 (PST)
MIME-Version: 1.0
Received: by 10.182.139.3 with HTTP; Sun, 11 Nov 2012 01:55:41 -0800 (PST)
In-Reply-To: <2b68ffd9dfb130ad660c16104ae26...@ruby-forum.com>
References: <0f55a4d2ca9d7cc93ebf82092582f...@ruby-forum.com>
<CAL=0gLtUsGBc0PsUrzn5=FoGjKZMF-S0vTMNtc7+CD3Ka13...@mail.gmail.com> <2b68ffd9dfb130ad660c16104ae26...@ruby-forum.com>
From: Colin Law <clan...@googlemail.com>
Date: Sun, 11 Nov 2012 09:55:41 +0000
Message-ID: <CAL=0gLt7sCjXSAfVqoX9=dgJOnotASowvyWuLWQyFWhJ9EM...@mail.gmail.com>
Subject: Re: [Rails] Re: help for ideas of instance method or controller
To: rubyonrails-talk@googlegroups.com
Content-Type: text/plain; charset=UTF-8
On 11 November 2012 09:24, Soichi Ishida <li...@ruby-forum.com> wrote:
>>
>> It looks to me as if you should only have one table for both give and
>> take. Is there a reason why this is not possible.
>
>
>
> You might be right. I will try that way.
> Thanks.
Note that you can have multiple associations into the same table using
and :class_name option. So for example
class Something
belongs_to :give, :foreign_key => "give_id", :classname => "Widget"
belongs_to :take, :foreign_key => "take_id", :classname => "Widget"
Have a look at the Rails Guide on ActiveRecord Associations for more
information.
Colin