brendon / ranked-model

An acts_as_sortable/acts_as_list replacement built for Rails 4+
https://github.com/mixonic/ranked-model
MIT License
1.09k stars 134 forks source link

Typo in Readme? #166

Closed husteadrobert closed 4 years ago

husteadrobert commented 4 years ago

In your section about migrating for existing data, you have the following:

# e.g. file db/migrate/20200325095038_add_row_order_to_ducks.rb
class AddRowOrderToDucks < ActiveRecord::Migration[6.0]
  def change
    add_column :courses, :row_order, :integer

    # Newest Duck shall rank "highest"" (be last).
    Duck.update_all('row_order = EXTRACT(EPOCH FROM created_at)')

    # Alternatively, implement any other sorting default
    # Duck.order(created_at: :desc).desc.each do |duck|
    #   duck.update!(row_order: duck.created_at.to_i + duck.age / 2)
    # end
  end
end

The add_column :courses, :row_order, :integer should instead be: add_column :ducks, :row_order, :integer, right? Or am I missing something?

brendon commented 4 years ago

Hehe, yep. That was probably a copy and paste error from the person who did the PR :) I'll fix it now :D