Displaying 3 results from an estimated 3 matches for "associationreflection".
2006 Apr 19
2
Using Reflections to find out ActiveRecord class association
...class Branch < ActiveRecord::Base
belongs_to :component
end
and then I do
Component.reflections[:branches].active_record
I would expect that to be Branch but it is in fact Component.
The inspection of Component.reflections is as below
{:branches=>#<ActiveRecord::Reflection::AssociationReflection:0x37d86d8
@active_record=Component, @primary_key_name="component_id", @options={},
@name=:branches, @macro=:has_many>
How can I get what class the has_many is to?
I am using Rails 1.1/Ruby 1.8.2
Thanks,
Steve Tuckner
--
Posted via http://www.ruby-forum.com/.
2010 Oct 06
2
reflect_on_association method
Hi all, I am having trouble trying to use reflect_on_association
method with given the simplified model:
class Order < ActiveRecord::Base
belongs_to :contractor, :class_name => "BusinessUnit"
end
I expected the reflect_on_association method to return
associated_foreign_key "contractor_id" but it returns
"business_unit_id":
ruby-1.9.2-p0 >
2007 Mar 18
7
How to get more informations about an association at runtime
Hi all
I''m working on a Custom Formbuilder. I want it to create me with a
single method call checkboxes for a given HABTM association.
My model looks like this:
[code=ruby]class Member < ActiveRecord::Base
has_and_belongs_to_many :preferred_music_styles,
:class_name => ''MusicStyle'',
:join_table =>