We at intinno use acts_as_paranoid so as not to permanently remove any data from the mysql tables. This also helps in restoring deleted data, if required.
Situation:
In Naarad(our erp solution for coaching institutes) users add teaching logs, which is basically a log book of which teacher taught which subject from what to what time. However your clients employ teachers which come and go. So teachers get added and deleted all the time. But if the teachers are deleted, then the logs refering to them would throw an error , saying the record doesn't exist.
Solution:
If we dont find the record, then try find_with_deleted first. If find with deleted fails, then render nil or blank
Basically instead of using
I now used
and force_find is defined as
Situation:
Ok now I can view the deleted record. But the logs can also be edited. So now the deleted records shoould be edited. But editing a deleted record sounded wierd.
Solution:
But there was a catch. In my case, logs corresponded to dates. So if a record is deleted, then it makes sense to edit its log entries before it was deleted. So in my app subjects had teachers and i defined a new method
Now while assigning teachers to log, all the teachers present on the system at a particular day are fetched.
Note: The above method in the application helper has been extracted out into a plugin. Read the details here.
Monday, September 28, 2009
Sunday, September 27, 2009
Friday, September 25, 2009
Thursday, September 17, 2009
Tuesday, September 15, 2009
Anything except rails
Its really difficult for me to do anything that doesn't involve ruby OR rails. I have a pending work in python which has been procrastinated beyond imagination. Time to roll up the sleeves and get it done.
Blogged with the Flock Browser
Sunday, September 13, 2009
Back after a long time
I had left this blog a long time ago and went for the wordress blog. Then I switched over to my self hosted blog. Wordpess blog was very difficult to update due to the heavy interface. The self managed blog ran really slow due to the dreamhost.com hosting.
Now Finally I'am back and I hope to post more frequently here due to the fact:
I am back to blogspot, from where I started.
Switched to flock and it should easily integrate to the blogspot.
Hope to see u here more frequently. :-)
Now Finally I'am back and I hope to post more frequently here due to the fact:
I am back to blogspot, from where I started.
Switched to flock and it should easily integrate to the blogspot.
Hope to see u here more frequently. :-)
Blogged with the Flock Browser
Subscribe to:
Posts (Atom)