ERROR:  column "refinery_pages.lft" must appear in the GROUP BY clause or be used in an aggregate functio
Correct could be: 

def nullify_duplicate_slugs_under_the_same_parent!
    t_slug = translation_class.arel_table[:slug]
    joins(:translations).group(:locale, :parent_id, t_slug, :lft).having(t_slug.count.gt(1)).count.
        each do |(locale, parent_id, slug), count|
      by_slug(slug, :locale => locale).where(:parent_id => parent_id).drop(1).each do |page|
        page.slug = nil # kill the duplicate slug
        page.save # regenerate the slug
      end
    end
  end