Lots of searching here and around suggested that you could use a second argument to send() to write a value to an attribute, but in Rails 4 you are told you have the wrong number of parameters:
> prj = Project.where(:id => 123).first
> fieldname = "project_start_date"
> prj.send(fieldname, Date.today)
ArgumentError : wrong number of arguments (1 for 0)
That approach was thought to be synonymous with
> prj.write_attribute(fieldname, Date.today)
But that errors with
NoMethodError : private method `write_attribute'
which is odd since the docs say this is a part of the instance public methods.
The ActiveRecord docs suggest using the class update method:
# Updates one record
Person.update(15, user_name: 'Samuel', group: 'expert')
# Updates multiple records
people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy" } }
Person.update(people.keys, people.values)
So what's a Rails 4 guy supposed to do?
In my case that would translate to:
Project.update(123, project_start_date: '2013/09/04') #not using variables for testing sake
and that yields me a nice:
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: zero-length delimited identifier at or near """"
LINE 1: ...dual".* FROM "project" WHERE "project"."" = $1 LI...
So what's a Rails 4 user supposed to use, other than writing out the actual SQL statements?