Displaying 1 result from an estimated 1 matches for "find_from_permalink".
2009 Jun 01
4
counter_cache is making a redundant SELECT before UPDATE
Hi,
I have the following code:
Message, belongs_to :topic, :counter_cache => true
topic = Topic.find_from_permalink(params[:id])
topic.messages.create(params[:message])
When the message gets created, then AR issues a supplemental SELECT to
retrieve the message''s topic and then updates its messages_count. Why is
that happening?
If I do it manually:
if topic.messages.create(params[:message])
topic.m...