Ruby on Rails
Tuesday, September 8, 2015
On Monday, September 7, 2015 at 11:48:50 PM UTC+1, Николай Спелый wrote:
This strange title is all that i think out.I have to objects: @user (instance of User model) and @chat (instance of Chat model).And i need to get record from table chats_users (relation has name chatusers) by these having objects, not by one of them and writing something like this: @user.chatusers.where(chat_id: @chat.id) or @chat.chatusers.where(user_id: @user.id).What i looking foor must looking like this:@user.double_relation(@chat, target: chatusers)
There is no such thing - you will have to write such a method yourself (which would just do chatusers.where(chat_id: chat) internally, assuming this is a method on user)
Fred
-- 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/3edf9321-a15f-4efb-b085-9299087ca2ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment