Reputation: 3
I have this in my object's save
class UploadFile < ActiveRecord::Base
def save
dir = 'public/data'
path = File.join(dir, 'nfile')
from = contents.path
contents = `cat #{from}`
super
end
end
contents stores a file object from a multi-part form submit.
This is very quick and dirty (yes I know cat #{from}
is probably not a good idea). Why is it that after super is called contents is # and not the contents of the file?
Thanks.
Upvotes: 0
Views: 1851
Reputation: 3069
Use the before_save callback http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html
Upvotes: 1