I am using the acts_as_taggable plugin, which works rather nicely by the way. My question is this: When using find_tagged_with, how do I sort the resultant data? It is currently sorting based on the "id" of the record. For instance, I have posts, with tags. If I want to find all posts tagged with "RubyOnRails" it displays them, but not in chronological order, they are displayed based on their id''s. I presume this wouldn''t normally be a problem, but I am populating my posts table in the database and the id''s aren''t in chronological order. I would like to sort the results of find_tagged_with by the created_on field. Thanks! -- Posted via http://www.ruby-forum.com/.
Vincent AE Scott
2006-Jun-13 16:25 UTC
[Rails] Sorting records from acts_as_taggable plugin
#if shane.pinnell /* Jun 02, 11:09 */> I am using the acts_as_taggable plugin, which works rather nicely by the > way. My question is this: When using find_tagged_with, how do I sort the > resultant data? It is currently sorting based on the "id" of the record. > For instance, I have posts, with tags. If I want to find all posts > tagged with "RubyOnRails" it displays them, but not in chronological > order, they are displayed based on their id''s. I presume this wouldn''t > normally be a problem, but I am populating my posts table in the > database and the id''s aren''t in chronological order. I would like to > sort the results of find_tagged_with by the created_on field.#endif /* shane.pinnell@gmail.com */ have a look at this: http://dev.rubyonrails.org/ticket/3928 Basically, find_tagged_with accepts an options paramater where you can define what :order gets passed to the actual find call. I Only just spotted this today, and have been pulling my hair out over :from, time for a post methinks. -- keys: http://codex.net/gpg.asc If voting changed anything, they''d make it illegal. -- Emma Goldman