dm-accepts_nested_attributes and _destroy

12 views
Skip to first unread message

mltsy

unread,
Jan 26, 2012, 10:27:59 AM1/26/12
to DataMapper
I'm wondering if the _destroy option for forms actually works with dm-
ANA the same as in ActiveRecord... ?

I have a model with:

accepts_nested_attributes_for :answers, :allow_destroy => true

and then in the form, inside the f.fields_for :answers block I have a
checkbox:

a.check_box, :_destroy

And whenever I load that page, I get an error the first time:

undefined method `to_i' for #<DataMapper::Resource::State::Immutable:
0x97f4794>

and the second time, all the answers are just gone. So it seems like
it's calling destroy on all the answers in the process of trying to
render the page... ?? Am I doing something wrong? Does dm-ANA not
support _destroy? I get the same weird results minus the error by
using simply :destroy (it destroys the object while rendering the
page). Do I need to do something in the Answer model perhaps?

Reply all
Reply to author
Forward
0 new messages