Behaviors that change data
Posted by on 2009-01-14 09:57
Hello,
Thanks for the IgnitedRecord. Its been a big help to me. However, I've run into a problem I can't figure out how to get around without editing the core IR classes, which I'd rather not do.
I've created a simple Upload behavior, that lets you handle uploads in a model without having to put in the boiler plate code to handle the uploads and deleting old files on deletes / updates. The behavior doesn't change any of the record's data until the save_pre_insert or save_pre_update hooks.
The problem is that if the only action a user wants to take is update the file information connected to an existing record, IR dies in IgnitedRecord::save() on the check to see if any changes have been made to the data (line 948 of the " IgnitedRecord 1.0 pre_release (rev218)
" download).
Is there some supported way of accomplishing this task in a behavior without changing the IR classes? If not, would you consider changing the classes to allow such behaviors, or would you take patches to do the same?
Thanks in advance,
Pete
Thanks for the IgnitedRecord. Its been a big help to me. However, I've run into a problem I can't figure out how to get around without editing the core IR classes, which I'd rather not do.
I've created a simple Upload behavior, that lets you handle uploads in a model without having to put in the boiler plate code to handle the uploads and deleting old files on deletes / updates. The behavior doesn't change any of the record's data until the save_pre_insert or save_pre_update hooks.
The problem is that if the only action a user wants to take is update the file information connected to an existing record, IR dies in IgnitedRecord::save() on the check to see if any changes have been made to the data (line 948 of the " IgnitedRecord 1.0 pre_release (rev218)
" download).
Is there some supported way of accomplishing this task in a behavior without changing the IR classes? If not, would you consider changing the classes to allow such behaviors, or would you take patches to do the same?
Thanks in advance,
Pete
Home / Developer API / Tour / Get a Project - Solutions for Bug & Issue Tracking, Collaboration Tools, Subversion Hosting, Git Hosting
Ignitedrecord is powered by Assembla.
4 Comments
By m4rw3r on 2009-01-14 11:21
The drawback is that this will always update the title column, even if it is unchanged, but it is the best option for now (going to fix the $force option).
By Anonymous on 2009-05-11 00:37
By Anonymous on 2009-07-09 16:28
By Anonymous on 2009-07-14 06:47