brendon / ranked-model

An acts_as_sortable/acts_as_list replacement built for Rails 4+

Home Page:https://github.com/mixonic/ranked-model

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clarify documentation around updating the position of an item

brendon opened this issue · comments

I actually went into the gem code to figure out that I'd not noticed the instructions to append _position to the column when updating the position of a row. Perhaps the documentation could be updated to emphasise that this is necessary, as simply specifying the column itself results in no error. Either that or raise an error if you receive key words like :up and :down as values for the actual column:

The ranking integers stored in the row_order column will be big and spaced apart. When you implement a sorting UI, just update the resource by appending the column name with _position and indicating the desired position:

IMPORTANT: Note that you must append _position to the column name when setting a new position on an instance. This is a fake column that can take relative as well as absolute values for position.