I stumble across some strange problem.
I have a model with a virtual attribute file_contents that is a string.
The model has validates_format_of :file_contents, :on => create, :unless
=> no_contents? (The method that returns file_contents.nil?)
Then, I have a before_create callback, where I get my model’s title and
description by parsing file_contents, and do write_attribute for title
The problem is, that it hangs the server. Forever. Looks like
write_attribute triggers validation again, and then before_create is
called again, and we get an infinite loop.
I’ve almost broke my brains but still hadn’t found a viable soultion.
Please, help with whatever you can!