I have a Post
model. I would like to let users create post comments while creating/updating a post by accepts_nested_attributes_for :comments
. However, I don't want to let users update comments by nested attributes.
Is there a way to do something like accepts_nested_attributes_for :comments, create_only: true
?
Try to use something like this accepts_nested_attributes_for :comments, reject: :persisted? This will check, if Post object persisted or not. You also can replace persisted? with your custom method
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With