Forum: Ruby on Rails Passing variables with update_all

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6b7c871c2036a41f0253580074b406cc?d=identicon&s=25 Nick C. (n1c)
on 2005-11-30 09:49
I'd like to produce an SQL update along the lines of:
UPDATE companies SET category2={newcategory} WHERE (category2 =
{oldcategory})

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.