On Thu, Jul 14, 2011 at 10:41 AM, Michael Pavling <[email protected]> wrote:

> On 14 July 2011 15:33, joanne ta <[email protected]> wrote:
> >> On 14 July 2011 15:12, joanne ta <[email protected]> wrote:
> >> >> > class Language < ActiveRecord::Base
> >> >> >   belongs_to :name, :class_name => "Phrase", :foreign_key => "name"
> >> >> >   belongs_to :phrase
> >> >> >   has_many :users
> >> >> > end
> >> >> > ~ language table
> >> >> > id
> >> >> > name
> >> >
> >> > is integer
> >> >>
> >> >> > directions
> >> >> > language_name
> >>
> >> PS Where's your phrase_id in the language table?
> >>
> > there is not phrase_id in language model
> > i use the name (phrase 's foreign key) ..
> > is there any syntax mistakes?
>
> In Language, you have "belongs_to :name" (which is really Phrase), and
> belongs_to :phrase. So you need a phrase_id field, and a name_id field
> - one for each of the relationships.
>

belongs_to phrase, I add it because the languageTest is complaining there is
no association with phrase.
so that i added it to language model

>
> In Phrase, you "has_many :languages", but language doesn't yet have a
> phrase_id field. Or did you mean for this has_many to point at the
> name_id field as foreign key?
>

yes. I want to point the name_id as foreign key of phrase

one phrase(id) can have many language (name_id/phrase_id)
I have so confused to have this warning..


please help and thanks for the quick reply.


> --
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to