trivektor
unread,Oct 5, 2011, 9:19:13 PM10/5/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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.