我试过这个:
User.find(1).update_attribute('first_name', '#{first.name.titleize}') => /#{first.name.titleize}
首先,需要使用双引号,ruby不会用单引号插入嵌入的变量。
u = User.find(1) u.update_attribute(:first_name, u.first_name.titleize)