brendon / acts_as_list

An ActiveRecord plugin for managing lists.
http://brendon.github.io/acts_as_list/
MIT License
2.04k stars 355 forks source link

warning: too many arguments for format string #239

Closed brendon closed 7 years ago

brendon commented 7 years ago

These warnings are popping up in the tests and I've isolated it to this method:

      define_singleton_method :update_all_with_touch do |updates|
        record = new
        attrs = record.send(:timestamp_attributes_for_update_in_model)
        now = record.send(:current_time_from_proper_timezone)

        query = attrs.map { |attr| "#{connection.quote_column_name(attr)} = :now" }
        query.push updates
        query = query.join(", ")

        update_all([query, now: now])
      end

Basically we end up with multiple copies of :now in the string but are only passing the one now: now into the update_all. I believe this might be a deeper rails bug but we could alleviate it possibly by naming each :now uniquely and passing all of those now's by name in as a hash.

Alternatively, is there a way to do all of this without resorting to string concatenation? Can't we build up the query as a hash and pass it in?