Problem with update query

20 views
Skip to first unread message

trivektor

unread,
Oct 5, 2011, 9:19:13 PM10/5/11
to Composite Keys for ActiveRecord
Hi,

I'm having an issue with update_attributes. I'm updating a keyword
with code = 123, value = "sample". My Keyword model has a composite
key (code, value)

k = Keyword.find(params[:code], params[:value])
k.keyword = params[:new_value]

(in the above, params[:code] = 123, params[:new_value] = "new sample")

When I call k.save and look at the generated SQL, here's what I found

UPDATE `keywords` SET `keyword` = 'new sample' WHERE `keywords`.`code`
= '8000833' AND `keywords`.`keyword` = 'new sample'

Therefore my keyword is not updated. Does anyone know what causes this
behavior and have any suggestion? Thanks.


cfis

unread,
Oct 19, 2011, 10:13:57 PM10/19/11
to Composite Keys for ActiveRecord
Any idea where the 8000833 is coming from?

Charlie
Reply all
Reply to author
Forward
0 new messages