Ruby on Rails Thursday, January 9, 2014

Sorry, just an edit for the code in the User model:
belongs_to :sender, foreign_key: 'sender_uid', class_name: 'User'
belongs_to :receiver, foreign_key: 'receiver_uid', class_name: 'User'



Robert Jewell wrote in post #1132668:

> Or in my User model, should I create the following associations:
> has_many :sent_messages, class_name: 'PrivateMessages',
> foreign_key: 'sender_uid'
> has_many :received_messages, class_name: 'PrivateMessages',
> foreign_key: 'receiver_uid'
>
> I really appreciate your feedback, Walter.
>

And now there's no more syntax Error

Robert Jewell wrote in post #1132668:
>
> However, when I enter, PrivateMessages, in rails console, I get a syntax
> error: syntax error, unexpected tSTRING_BEG, expecting =>
> belongs_to :sender, foreign_key: 'sender_uid', :class_name 'User'
>
> The same error appears for receiver_uid...

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/52466cb421d3e8030a9412f79e700d0c%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment