JackDanger / permanent_records

Rails Plugin - soft-delete your ActiveRecord records. It's like an explicit version of ActsAsParanoid
https://jdanger.com
MIT License
272 stars 64 forks source link

Destroying hmabt association returns 'undefined method' error #94

Closed ramilsitdikov closed 6 years ago

ramilsitdikov commented 7 years ago

class FooBar < ApplicationRecord
  has_and_belongs_to_many :baz_qux
end

class BazQux < ApplicationRecord
  has_and_belongs_to_many :foo_bar
end

class CreateJoinTableBazQuxFooBar < ActiveRecord::Migration[5.1]
  def up
    create_table :baz_qux_foo_bar, id: false do |t|
      t.references :baz_qux
      t.references :foo_bar
    end
  end
end

FooBar model has deleted_at column

Let's we have a f_b = FooBar.create

When we try to destroy it we got a error undefined method 'foobar_baz_qux'