Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Circular References in Ruby

Status
Not open for further replies.

grande

Programmer
Feb 14, 2005
657
CA
I have a question about circular references. How would I accomplish this?

I want to make a Category that can have any number of sub-categories.

Would it just be like this?

Code:
class Category < ActiveRecord::Base

    belongs_to :category, has_many :category, :class_name => "Category", :foreign_key => "parent_id"

end

Any help would be greatly appreciated.
(I apologise, I'm pretty new at this)

-------------------------
Call me barely Impressive Captain.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top