[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: ActiveRecord (not necessarily rails

Igor Sutton Lopes

6/27/2007 8:19:00 PM

Hi,

On Jun 27, 2007, at 4:05 PM, shawn bright wrote:

> Hello all,
> i have been using ActiveRecord in a couple of GUI applications
> recently and
> it is working really well.
> i was wondering though, if it is possible to have a class defined
> that i can
> change one of the has_many or belongs_to declarations
> dynamically. In a model, i declare one like this.
>
> class Person ActiveRecord::Base
> has_many :records
>
> now, is the has_many some sort of attribute, class variable, etc...
> i mean if in my program, i wanted to change the
> has_many :records to something like
> has_many :hats

<code>
has_many :hats, :class_name => 'Record', :foreign_key => 'hat_id'
</code>

Good luck!

--
Igor Sutton
igor.sutton@gmail.com