Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.1 Error on duplication #79

Open
bekkblando opened this issue Jun 29, 2017 · 1 comment
Open

Version 3.1 Error on duplication #79

bekkblando opened this issue Jun 29, 2017 · 1 comment

Comments

@bekkblando
Copy link

Error: NoMethodError Exception: undefined method 'macro' for nil:NilClass

We've only been experiencing this error using the 3.1 version and I have confirmed that we are using include_association only on associations so I do not believe it's issue 36.

For now we will continue to use 3.0, but any ideas on what the issue may be would be appreciated.

@codeinaire
Copy link

I'm using Rails 5.2 and Amoeba 3.1

Problem

pry(main)> tariff.amoeba_dup

NoMethodError: undefined method `macro' for nil:NilClass
from /usr/local/bundle/gems/amoeba-3.1.0/lib/amoeba/cloner.rb:110:in `follow_association'

Relevant Code

This is the amoeba block in tariff.rb:

amoeba do
    include_association [:standing_charges, :volume_charges, :capacity_charges]
    nullify [:workflow_state]
    append title: I18n.t('admin.tariffs.actions.clone') || '(cloned)'
  end

These are the relevant associations:

class Tariff < ApplicationRecord

  has_many :standing_charges, -> { order(title: :asc) }, dependent: :destroy, inverse_of: :tariff
  has_many :volume_charges, -> { order(title: :asc) }, dependent: :destroy, inverse_of: :tariff
  has_many :capacity_charges, -> { order(title: :asc) }, dependent: :destroy, inverse_of: :tariff

end

All of the above three models have a belongs_to association with Tariff

Solution (temporary?)

Change the amoeba block in tariff.rb to:

amoeba do
        include_association :standing_charges
        include_association :volume_charges
        include_association :capacity_charges
end

I'm not sure if this is a bug or not. The solution I have will be fine to fix the problem for our application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants