On 12 March 2011 12:59, Paul Bergstrom
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> I have 3 tables; Feelings, Users, and Members. Both Feelings and Members
> belongs_to Users with user_id.
>
> Both models Feelings and Members have belongs_to :user in them. Feelings
> has has_one :member, :through => :user.
The above would be easier for us (well, me anyway) to understand if
you showed the class definitions
feeling.rb
class Feeling < ActiveRecord::Base
belongs_to :user
and so on. Also tell us the file names. Copy and paste from your
code in case of typo errors.
>
> Is this the right setup? How can I make a rails search condition in
> Feelings and get a column from members into that search?
I am not exactly sure what you want, but once you find Feeling object
@feeling = Feeling.first for example, then, if the relationships are
correct, the member can be accessed by
@feeling.member
so columns can be accessed by
@feeling.member.name or whatever.
You can check whether it is working by using the rails console and
typing things like
f = Feeling.first
f.member
f.member.name
Colin
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.