Giter Site home page Giter Site logo

_destroy doesn't work about nested_form HOT 8 CLOSED

ryanb avatar ryanb commented on July 30, 2024
_destroy doesn't work

from nested_form.

Comments (8)

cmezak avatar cmezak commented on July 30, 2024 1

It might be good to mention in the readme the need for :allow_destroy => true in the accepts_nested_attributes_for call.

from nested_form.

ryanb avatar ryanb commented on July 30, 2024

That's strange, I'm not sure what the issue could be. Do you have attr_accessible in the image model? You can try adding _destroy there but you shouldn't have to.

You can check out the nested_form branch of the complex-form-example project for a working example.
https://github.com/ryanb/complex-form-examples/tree/nested_form

from nested_form.

phlegx avatar phlegx commented on July 30, 2024

How can I debug "the model" to find the problem? I use the following in the parent model:

attr_accessible ..., :avatars_attributes

has_many :avatars, :as => :avatarable, :dependent => :destroy   
accepts_nested_attributes_for :avatars, :allow_destroy => true

[SOLVED] Problem solved. I have moved the code above to the superclass. If the code is in the subclass model than the destroy doesn't work!

from nested_form.

ryanb avatar ryanb commented on July 30, 2024

Glad you got it solved, that's a strange bug but thank you for reporting.

from nested_form.

ryanb avatar ryanb commented on July 30, 2024

Good point. I'll reopen this for that readme addition.

from nested_form.

tralles avatar tralles commented on July 30, 2024

i had the same problem in rails 3.1.0.rc8 - but to add :allow_destroy => true does the trick - also today in rails 3.1 …
thanks for this gem :)

from nested_form.

derekprior avatar derekprior commented on July 30, 2024

See pull request 88 for the readme update.

from nested_form.

lest avatar lest commented on July 30, 2024

#88 was merged. Thanks!

from nested_form.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.