I think I'm still missing something. You should be able to put the ":dependent => :destroy" on the join has_many, but leave it off of the has_many :through:

  has_many :employees, :accessible => true, :dependent => :destroy
  has_many :companies, :through => :employees, :order => :name

Bryan

François Beausoleil wrote:
Hi!

My parent models are plain old has_many (POHM ? :)). And no, I don't
want :dependent => :destroy.  The company and person records are fine
as they are.  It's the join model which I want destroyed, not
nullified.

class Person < AR::B
  hobo_model
  has_many :employees, :accessible => true
  has_many :companies, :through => :employees, :order => "name"
end

class Company < AR::B
  hobo_model
  has_many :employees, :accessible => true
  has_many :people, :through => :employees, :order => "name"
end

Thanks!
François

On 5 fév, 13:19, kevinpfromnm <[email protected]> wrote:
Actually, doesn't sound like dependent destroy as he's talking about
unlinking employee (join model) from person.  Sounds like instead of
unlinking, you actually want to destroy the join model, which from the
view code you posted, that's what it should be doing.   Unless you're
talking about deleting the company record and not the employee record.

Might be helpful to post the relevant associations of your Person and
Company models as well.

On Feb 4, 9:28 pm, Bryan Larsen <[email protected]> wrote:



You're looking for the :dependent => :destroy option to has_many, I
believe.  That's part of Rails, not Hobo.
Bryan
Fran ois Beausoleil wrote:
Hi all!
I have an employee model like this:
class Employee < ActiveRecord::Base
  hobo_model
  fields do
    timestamps
  end
  belongs_to :company
  belongs_to :person
  validates_uniqueness_of :person_id, :scope => :company_id
end
I'm on a Person page, where I have the has-many editor:
<extend tag="form" for="Person">
  <old-form merge>
    <field-list: fields="name, employees">
      <employees-view:>
        <input-many>
          <field-list fields="company"/>
        </input-many>
      </employees-view:>
    </field-list:>
  </old-form>
</extend>
UI-wise, things work out: I can add / remove employee records.  I'd
like the association record to be destroyed when I unlink the employee
from the person.  How does that work?
I read the source code, to see how it was implemented.  I can't seem
to find it at all:
http://github.com/tablatom/hobo/blob/master/hobo/lib/hobo/accessible_...
Thanks!
Fran ois


--
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to