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

Rails 3.0.3 You cannot call create unless the parent is saved #34

Closed
dgm opened this issue Nov 20, 2010 · 7 comments
Closed

Rails 3.0.3 You cannot call create unless the parent is saved #34

dgm opened this issue Nov 20, 2010 · 7 comments

Comments

@dgm
Copy link
Contributor

dgm commented Nov 20, 2010

Using the current rails3 branch ... I think rails 3.0.3 introduced a bug. It works on rails 3.0.1, but when I update to rails 3.0.3, I get:

activerecord (3.0.3) lib/active_record/associations/association_collection.rb:550:in `ensure_owner_is_not_new'
activerecord (3.0.3) lib/active_record/associations/association_collection.rb:494:in `create_record'
activerecord (3.0.3) lib/active_record/associations/association_collection.rb:269:in `create'
/Users/dgm/.rvm/gems/ruby-1.9.2-p0@cumpp/bundler/gems/acts_as_audited-574ae9e4d49a/lib/acts_as_audited/auditor.rb:204:in `write_audit'
/Users/dgm/.rvm/gems/ruby-1.9.2-p0@cumpp/bundler/gems/acts_as_audited-574ae9e4d49a/lib/acts_as_audited/auditor.rb:199:in `audit_destroy'
@dgm
Copy link
Contributor Author

dgm commented Nov 20, 2010

Possible fix: change it to a before_destroy rather than an after_destroy operation, so the create() call occurs on an object that exists.

@ghost
Copy link

ghost commented Nov 29, 2010

I am also getting this error since Rails 3.0.3. Could you please elaborate a bit where to make the mentioned changes?

@dgm
Copy link
Contributor Author

dgm commented Nov 29, 2010

see my pull request in issue 36

@ghost
Copy link

ghost commented Nov 29, 2010

ah, thank you. This bug is now gone. But I am still getting the mass assign of protected attributes error.

@kennethkalmer
Copy link
Collaborator

Also fixed in part by bb38256.

@scnaegle
Copy link

I am still getting this exact same error. I am using rails 3.0.5 and acts_as_audited 2.0.0.rc7
Here is the trace I get:

activerecord (3.0.5) lib/active_record/associations/association_collection.rb:551:in `ensure_owner_is_not_new'
activerecord (3.0.5) lib/active_record/associations/association_collection.rb:495:in `create_record'
activerecord (3.0.5) lib/active_record/associations/association_collection.rb:271:in `create'
acts_as_audited (2.0.0.rc7) lib/acts_as_audited/auditor.rb:215:in `write_audit'
acts_as_audited (2.0.0.rc7) lib/acts_as_audited/auditor.rb:209:in `audit_destroy'
activesupport (3.0.5) lib/active_support/callbacks.rb:414:in `_run_destroy_callbacks'
activerecord (3.0.5) lib/active_record/callbacks.rb:260:in `destroy'
activerecord (3.0.5) lib/active_record/transactions.rb:235:in `destroy'
activerecord (3.0.5) lib/active_record/transactions.rb:292:in `with_transaction_returning_status'
activerecord (3.0.5) lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
activerecord (3.0.5) lib/active_record/transactions.rb:207:in `transaction'
activerecord (3.0.5) lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
activerecord (3.0.5) lib/active_record/transactions.rb:235:in `destroy'

@scnaegle
Copy link

https://github.com/collectiveidea/acts_as_audited/pull/79
This fixes it for my case, which is a form that removes duplicate entries before they even get saved.

This issue was closed.
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

3 participants