Forum: Ruby on Rails Passing variables with update_all

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Nick C. (Guest)
on 2005-11-30 10:49
I'd like to produce an SQL update along the lines of:
UPDATE companies SET category2={newcategory} WHERE (category2 =

At the moment I've got:

ctype = params[:ctype]
Company.update_all("category2=ctype", "category2=ctype")

At present this returns a StatementInvalid:
Unknown column 'ctype' in 'where clause': UPDATE companies SET
category2=ctype WHERE (category2 = ctype)

Can anyone tell me how I can pass the variable successfully?
This topic is locked and can not be replied to.