I would like to know which "has_many" associations my ActiveRecord
model
has.
Example, given this model:
class Post < ActiveRecord::Base
has_many :comments
end
I need a method that does this:
@associations = Post.has_many_associations
@association.each do |a|
puts a # should print "comments"
end
Can you help me ? This method exists ? Is it possible ?
Thanks
--
Posted via http://www.ruby-forum.com/.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
not perfect yet, but there is something like this...: Post.reflect_on_association :comments ..that returns a boolean... Not perfect yet..but helps... -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sep 29, 3:09 pm, Anderson Leite <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> not perfect yet, but there is something like this...: > > Post.reflect_on_association :comments > > ..that returns a boolean... >It should be returning a reflection object. see also the reflections method and reflect_on_all_associations Fred> Not perfect yet..but helps... > -- > Posted viahttp://www.ruby-forum.com/.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.