Can I use the ‘magic’ _destroy attribute that works for accepts_nested_attributes_for for a regular form_for helper?
I have a file that I’m uploading via Paperclip and I’d like to have the option to delete it.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes indeed – here’s a contrived example in Haml.
And in the model:
EDIT – NEW ANSWER: Yes, you can, but it’s less “magical”. You need to define your own virtual attribute on the model to be checked prior to the save. Here’s an (untested) example that does not use nested attributes:
And in the model:
See Railscasts #167 for a more detailed explanation of virtual attributes.