Relation passed to #or must be structurally compatible. Incompatible values: [:references]

There is a known issue about it on Github. According to this comment you might want to override the structurally_incompatible_values_for_or to overcome the issue: def structurally_incompatible_values_for_or(other) Relation::SINGLE_VALUE_METHODS.reject { |m| send(“#{m}_value”) == other.send(“#{m}_value”) } + (Relation::MULTI_VALUE_METHODS – [:eager_load, :references, :extending]).reject { |m| send(“#{m}_values”) == other.send(“#{m}_values”) } + (Relation::CLAUSE_METHODS – [:having, :where]).reject { |m| send(“#{m}_clause”) == other.send(“#{m}_clause”) … Read more

Grouping by week/month/etc & ActiveRecord?

In Postgres you can do: @user.comments.group(“DATE_TRUNC(‘month’, created_at)”).count to get: {“2012-08-01 00:00:00″=>152, “2012-07-01 00:00:00″=>57, “2012-09-01 00:00:00″=>132} It accepts values from “microseconds” to “millennium” for grouping: http://www.postgresql.org/docs/8.1/static/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC

Batch insertion in rails 3

ActiveRecord .create method supports bulk creation. The method emulates the feature if the DB doesn’t support it and uses the underlying DB engine if the feature is supported. Just pass an array of options. # Create an Array of new objects User.create([{ :first_name => ‘Jamie’ }, { :first_name => ‘Jeremy’ }]) Block is supported and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)