Ask A Question

Notifications

You’re not receiving notifications from this thread.

Active Storage Validations Gem and Active Storage problems in nestted params

wtfchamp asked in Rails

gem active_storage_validations 1.0.3
I have two models with "has_one_attached :image", 1 model is created with a form, and the second model is created "after_created callback", when i try to update, the :image for my first model, the validation "attached: true" doesn´t work, the solution that i use is using this line @my_model.image.attach(params[:my_model][:image]) and it works!
But, In my second model, when i try to update the image doing the same logic only works on the first attempt,and the second attempt throws me an error "undefined method 'attachment_reflections' for nil:NilClass", the solution for this and i know is very very very wrong is using puts @my_model.image.attached?.

What am I doing wrong, what errors would it cause in Active Storage and what possible solutions are there?

Thank you for your read my questions and sorry for my bad english )

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.