Forum: Ruby on Rails How to remove the orignal file in carrierwave

Posted by Loganathan S. (loganathan_s)
on 2012-10-08 10:45
(Received via mailing list)
HI All,

I am using the carrier wave gem for file uploading, and I am not able to
delete the original file after  uploading. I tried the below code but it
didn't work, any help would be really appreciated.

*
 after :store, :unlink_original

  def unlink_original(file)
    File.delete(store_dir+'/'+@original_file) #path of the original file
  end*

regards,
Loganathan
Mob: +91 7760780741 | +91 9944414388
Skype: loganathan.sellappa
ViewMe <http://vizualize.me/loganathan>
Posted by rubyonrailsx (Guest)
on 2012-10-17 11:00
(Received via mailing list)
How about File.unlink instead of File.delete


--
rubyonrailsx
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
Posted by Colin Law (Guest)
on 2012-10-17 11:31
(Received via mailing list)
On 8 October 2012 09:42, Loganathan Sellapa <loganathan.ms@gmail.com> 
wrote:
>     File.delete(store_dir+'/'+@original_file) #path of the original file
>   end

Have you confirmed that unlink_original is being called and that the
correct file name is being built and passed to delete?  If you have
not already done so then I suggest logging a message showing the value
os
store_dir+'/'+@original_file and makes sure that it appears ok.
Alternatively break in with the debugger to make sure it is ok.

Colin
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.