Maarten Hendrikx
2006-May-30 06:29 UTC
[Rails] Order parents when displaying children question
Hi, I want to show a series of links belonging to a specific category. The links will be shown grouped by category, but how can I alter the order of the categories? I have a field in my database called position with the order in which they should appear. MODELS: class Category < ActiveRecord::Base has_many :links validates_uniqueness_of :category, :message => "already exists" end class Link < ActiveRecord::Base belongs_to :category validates_associated :category validates_presence_of :link validates_presence_of :url def self.get_links find(:all, :order => :category_id) end end Any help would be great! Maarten -- Posted via http://www.ruby-forum.com/.