I have a category list which the customer wants administratively to define the sort order, instead of alphabetical or whatever. The obvious approach seems to be to put a sort_order int on the record and use this as the presentation sort order. Then to shift the item up in the sort order to swap the current and the prevous item in the sort_order. Does this seem like a sensible approach, or is there an easier way? _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Oct 4, 2005, at 9:39 PM, matthew newhook wrote:> I have a category list which the customer wants administratively to > define the sort order, instead of alphabetical or whatever. The > obvious approach seems to be to put a sort_order int on the record > and use this as the presentation sort order. Then to shift the item > up in the sort order to swap the current and the prevous item in > the sort_order. > > Does this seem like a sensible approach, or is there an easier way?Yes! http://rails.rubyonrails.org/classes/ActiveRecord/Acts/List/ ClassMethods.html#M000442 Best, jeremy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) iD8DBQFDQ3BQAQHALep9HFYRAh6lAKCzWVY+UF9+ONi5H+oUApOiBFwnzQCgwTVf lxQ/VETz9Gan2NjAdPIztss=1cKD -----END PGP SIGNATURE-----
Ok, that''s awesome :) Matthew On 10/5/05, Jeremy Kemper <jeremy-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org> wrote:> > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Oct 4, 2005, at 9:39 PM, matthew newhook wrote: > > I have a category list which the customer wants administratively to > > define the sort order, instead of alphabetical or whatever. The > > obvious approach seems to be to put a sort_order int on the record > > and use this as the presentation sort order. Then to shift the item > > up in the sort order to swap the current and the prevous item in > > the sort_order. > > > > Does this seem like a sensible approach, or is there an easier way? > > Yes! http://rails.rubyonrails.org/classes/ActiveRecord/Acts/List/ > ClassMethods.html#M000442 > > Best, > jeremy > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.2 (Darwin) > > iD8DBQFDQ3BQAQHALep9HFYRAh6lAKCzWVY+UF9+ONi5H+oUApOiBFwnzQCgwTVf > lxQ/VETz9Gan2NjAdPIztss> =1cKD > -----END PGP SIGNATURE----- >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails