0

While trying ro resolve my previous question, I faced with an interesting thing that I do not understand: I had an ActiveRecord object restream that references to another object provider. At the end I faced with the thing that restream.update_attributes(provider: new_provider) do not save anything until I make restream.reload.update_attributes(provider: new_provider).

Why does it work so and can't save the object without reloading it? Is it somehow connected with that restream could be changed in some other thread? One more thing is that no errors are added by restream.update_attributes(provider: new_provider). If it can't update a record, why does it keeps silent?

Thanx!

Community
  • 1
  • 1
Ngoral
  • 4,215
  • 2
  • 20
  • 37
  • When running `restream.update_attributes(provider: new_provider)` what does `puts restrem.errors.inspect` output? – Dan Andreasson Oct 03 '16 at 07:12
  • http://stackoverflow.com/questions/22259641/why-use-reload-method-after-saving-object-hartl-rails-tut-6-30 - this may help you. – APS Oct 03 '16 at 07:48
  • @DanAndreasson !! I've just edited the post, to point out that it's just keeping silent. No errors, no warning in logs, nothing. I needed 4 days to find this thing. – Ngoral Oct 03 '16 at 08:30
  • @AnkitaSurani I know what does `reload` do, I don't realise why nothing works without it in that case – Ngoral Oct 03 '16 at 08:32

0 Answers0