Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Daniel Lunde's latest activity

Friday, May 02 2008
82 Iterate over :has_many array with the join (:through) model was updated in Ruby on Rails
  • Daniel Lunde
    Daniel Lunde commented at 4:42 PM

    Here's a real world example where I've needed to use each_with_join:

    class Feature < ActiveRecord::Base
      has_many :featured_items, :dependent => :destroy, :...
  • Daniel Lunde
    Daniel Lunde commented at 4:14 PM

    Pratik:

    It seems like the obvious thing to do, but there's a problem with it. Let me give a more complete example.

    >> pp frank.groups
    [#<Group id: 2, name:...
Thursday, May 01 2008
82 Iterate over :has_many array with the join (:through) model was updated in Ruby on Rails
  • Daniel Lunde
    Daniel Lunde commented at 9:22 PM

    What about the cases where you are sorting by groups

    class User < ActiveRecord::Base
       has_many :memberships
       has_many :groups, :through => :memberships,...
  • Daniel Lunde
    Daniel Lunde created the ticket at 5:28 PM

    It is often the case when I iterate over an array of objects in a has_many_through association that I want access to both the :has_many objects and the :throug...