> Can you not just do @topic.messages << @message
> 
then the message is missing the user_id.

A found a way:

message = user.messages.build(:content => 'blabla')
topic.messages << message.

But to update the counter columns, then rails does 2 redundant select 
queries: one for topic and one for user then updates the counter 
columns, although user and topic objects are already available.

I could code that manually but it doesn't look pretty. I think some time 
ago Fred Cheung said that intelligent reserve associations would be 
available in Rails 3, for now rails has to do redundant selects in order 
to update the objects. Maybe there is another and better way to achieve 
what I want?
-- 
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 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