开发者

Acts_as_list descending instead of ASC numbering

开发者 https://www.devze.com 2022-12-18 22:20 出处:网络
I\'m using acts_as_list plugin to sort my to do lists. * [drag] Test 1 * [drag] sadf 2 * [drag] asdf 3

I'm using acts_as_list plugin to sort my to do lists.

* [drag] Test 1
* [drag] sadf 2
* [drag] asdf 3 

However I want the numbering to the DESC instead. So it shows as

* [drag] Test 3
* [drag] sadf 2
* [drag]开发者_开发技巧 asdf 1

How do I do that?

Thanks


Try changing the order in the model:

class TodoList < ActiveRecord::Base
  has_many :todo_items, :order => "position DESC"
end

That should produce:

  • asdf 3
  • sadf 2
  • Test 1

assuming your items are:

id name position
1  Test 1
2  sadf 2
3  asdf 3
0

精彩评论

暂无评论...
验证码 换一张
取 消