Open traels opened 9 years ago
Have now found some more info - this started happening in a new project - in development. Failing flow: CChild.find({parent_id: 123}).first # which returns nothing, and should c = CChild.new c.name = 'Simon' # undefined method :name for {}:CChild (in Rfm::Base line 255)
To make it work: (that is, after restarting console!) CChild.new CChild.find({parent_id: 123}).first # which returns nothing, and should c = CChild.new c.name = 'Simon' Now everything works ... !!!
My guess is that somewhere along the road the first call to a layout will cache the field names, and if no field names are returned then that class will be (forever?) useless.
Any help on fixing this will be greatly appreciated - for now I think I'll just do a .new for each of my models in an initializer to make sure all classes have cached some fieldnames :)
I know I just posted this as a comment to another issue, but found that this might be something entirely different. I'm using Rfm models and after a Policy.create (or .new followed by as save) I got "undefined method `id' for {}:Policy". When accessing .id on my instance. It has happend a few times, no exceptions are raised in Rfm, the model is just an empty hash after create. I created a few tests and ran it alot of times and it did not happen, so far I've only seen it in production :-( I am using the newest version of Rfm. I've set it to log requests, no request is registered in my Rails app, and nothing is registered in FM, it is like new/initialize in rfm record can fail and just return a blank hash. I see there is some commented out rescue code that seems to indicate that it has been an issue before. I'd really like to solve this, and I'll be glad to cook up a PR on this, but I need some hints to where I should go look for this issue. I would hate to go back to write FM we stuff in PHP :-(