11155
(-- --)
1
Hi
Here I am trying to get the details of changed fields in update method
I got those fields by changes method. #obj.changes
But problem is that I got changes in following ways even when I am not
updating anything.
obj.changes
{"address"=>[nil, ""]}
This is what I don't want. I want only those changes which are text to
blank or blank to text or text to text..
Can anybody help me ?
Thanks
Brijesh Shah
Just filter out the ones where the two array entries are nil and "".
Note that blank? will probably be useful here.
Colin
11155
(-- --)
3
Colin Law wrote in post #971987:
Just filter out the ones where the two array entries are nil and "".
Note that blank? will probably be useful here.
Colin
Thanks for reply. But how can I filter this one?
Currently I am checking the field change and avoid nil to blank changes.
like if !obj.changes["address] != [nil,""]
---More ----
end
Note: There are multiple fields to check.
Thanks
Brijesh Shah
Run through the hash first removing items for which both elements of
its array respond true to .blank? Have a look at Hash.delete_if for
example.
Colin
11155
(-- --)
5
Hi
Thanks Colin. This should works fine..
Thanks
Brijesh Shah