CSV problem with migration but working fine in controller

I'm getting problem with csv. When I use below code in my Controller
method then it works but when I put this in my migration then this don't
work. Why so

Put in some debug to work out what is going wrong. Is it executing
self.up? Is it finding the file? Does it find any rows? Does the
save fail (it might be worth testing this first by checking the return
from save, perhaps validations are failing).

Have a look at the Rails Guide on Debugging for debugging techniques.
Knowing how to debug is one of the most important skills, in five
minutes debugging you can save the time spent asking questions and
waiting hours for help.

Colin