11155
(-- --)
1
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
11155
(-- --)
2
not perfect yet, but there is something like this...:
Post.reflect_on_association :comments
..that returns a boolean...
Not perfect yet..but helps...
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