On Tue, Apr 20, 2010 at 12:51 PM, Fearless Fool <li...@ruby-forum.com> wrote:
> Frederick Cheung wrote:
>> for a normal HABTM there is no corresponding model, so rows never get
>> updated by this code path. The habtm association generates sql
>> fragments directly and runs them
>> Furthermore, because habtm is usually used as a  'dumb' join table,
>> it's only ever a question of deleting or inserting rows
>>
>> Fred
>
> Enlightenment is a slow process, at least for me.
>
> So I think what's going on is that I've created a table that *should* be
> declared as HABTM.  And now that I think about it in those terms, I'm
> not sure why I didn't to that in the first place.
>
> Time for another "script/generate migration"...
>

Actually, I think what you want is to use has_many :through

1. add an id to metered_usages

2. class MeterUsage
       belongs_to :service_address
       belongs_to :metered_service
    end

    class ServiceAddress
      has_many :metered_usages
      has_many :metered_services, :through => :metered_usages
    end

    class MeteredService
      has_many :metered_usages
      has_many :service_addresses, :through => :metered_usages
    end




-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to