rubyonrailsin

A Ruby and Rails talk

Friday, March 19, 2010


[Rails] Re: getting data from a through table

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

thanks for the suggestions

attributes is a self inherited table
so i need to get them i order of top level and down
this is part of my current solution

has_many :objects_attributes do
def top_level
all(:joins => :attribute, :conditions => "attributes.parent_id
is null")
end

def children(id)
all(:joins => :attribute, :conditions => ["attributes.parent_id
= ?", id])
end
end

this allows me to access all fields in order desired
thanks for your help

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive