Thomas Nitsche
2006-Mar-26 16:50 UTC
[Rails] How to delete a uploaded file with file_column plugin?
Hi, sounds somehow stupid, but I can''t get rid of my files that I uploaded into my application via the file_column plugin. Any suggestions? Cheers Thomas -- Posted via http://www.ruby-forum.com/.
Roberto Saccon
2006-Mar-26 16:55 UTC
[Rails] How to delete a uploaded file with file_column plugin?
Just destroy the record (which has a file-column) and the file gets removed. On 3/26/06, Thomas Nitsche <thomas.nitsche@gmail.com> wrote:> > Hi, > > sounds somehow stupid, but I can''t get rid of my files that I uploaded > into my application via the file_column plugin. Any suggestions? > > Cheers > > Thomas > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Roberto Saccon - http://rsaccon.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060326/8f2de31e/attachment.html
Thomas Nitsche
2006-Mar-26 17:10 UTC
[Rails] Re: How to delete a uploaded file with file_column plugin?
I can''t do that, because the ''file_columned'' record is a user and I don''t want to destroy the whole user account ;-) Actually I just want to reset the file column. Maybe I should try it with a own model for uploaded files - that way I could destroy the related record without any pain Thx Thomas -- Posted via http://www.ruby-forum.com/.
John Tsombakos
2006-Mar-26 23:43 UTC
[Rails] Re: How to delete a uploaded file with file_column plugin?
I''m pretty sure if you set the column that you have defined as your image to "", the file will be removed. jt On 3/26/06, Thomas Nitsche <thomas.nitsche@gmail.com> wrote:> > I can''t do that, because the ''file_columned'' record is a user and I > don''t want to destroy the whole user account ;-) Actually I just want to > reset the file column. Maybe I should try it with a own model for > uploaded files - that way I could destroy the related record without any > pain > > Thx > > Thomas > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Thomas Nitsche
2006-Mar-27 08:37 UTC
[Rails] Re: Re: How to delete a uploaded file with file_column plugi
John Tsombakos wrote:> I''m pretty sure if you set the column that you have defined as your > image to "", the file will be removed.I tried both "@user.image = ''''" and "@user.image = nil". The first one just does nothing and the second one produces an error. So, no luck this time ;-) Cheers Thomas -- Posted via http://www.ruby-forum.com/.
Mats Lindblad
2006-Mar-27 08:43 UTC
[Rails] Re: Re: How to delete a uploaded file with file_column plugi
Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 250 bytes Desc: OpenPGP digital signature Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060327/07f7d962/signature.bin
Noel R. Morais
2006-Mar-27 12:44 UTC
[Rails] Re: How to delete a uploaded file with file_column plugin?
does''nt work! On 3/26/06, John Tsombakos <johnt519@gmail.com> wrote:> I''m pretty sure if you set the column that you have defined as your > image to "", the file will be removed. > > jt > > On 3/26/06, Thomas Nitsche <thomas.nitsche@gmail.com> wrote: > > > > I can''t do that, because the ''file_columned'' record is a user and I > > don''t want to destroy the whole user account ;-) Actually I just want to > > reset the file column. Maybe I should try it with a own model for > > uploaded files - that way I could destroy the related record without any > > pain > > > > Thx > > > > Thomas > > > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- _________ Noel R. Morais
John Tsombakos
2006-Mar-28 07:19 UTC
[Rails] Re: How to delete a uploaded file with file_column plugin?
On 3/27/06, Noel R. Morais <noelrocha@gmail.com> wrote:> does''nt work! >Hmm.. That''s all I had to do. Actually, now that I think about it, I''m not sure if it did delete the file. I''ll have to do some testing. jt
ian parkins
2006-Mar-28 08:07 UTC
[Rails] Re: How to delete a uploaded file with file_column plugin?
Thomas Nitsche wrote:> > I can''t do that, because the ''file_columned'' record is a user and I > don''t want to destroy the whole user account ;-) Actually I just want to > reset the file column. Maybe I should try it with a own model for > uploaded files - that way I could destroy the related record without any > pain > > Thx > > ThomasModifying the DB schema is indeed the right way to go here for sure, regardless of how easy/hard it is to work with the image as part of the user model. -- Posted via http://www.ruby-forum.com/.
Thomas Nitsche
2006-Mar-28 20:54 UTC
[Rails] Re: How to delete a uploaded file with file_column plugin?
ian parkins wrote:> Modifying the DB schema is indeed the right way to go here for sure, > regardless of how easy/hard it is to work with the image as part of the > user model.Yeah, I split off things and now have an user and an image table/model. And it works like a charm :-) Moreover I declared "user has_many: images" which is much cooler than before. Thx Thomas -- Posted via http://www.ruby-forum.com/.
Jared Mr.
2006-Oct-31 19:14 UTC
Re: How to delete a uploaded file with file_column plugin?
I ran into this same issue, and noticed the following: (assume model User and file_column :file) after @user.file is called, a variable called @file_state is added to the @user instance, which contains an instance of PermanentUploadedFile, the class that file column uses for its operation. If you expose the @file_state variable, you can then call all the methods in the PermanentUploadedFile class, including delete_files, which removes the directory and everything in it for the current file_column. You can do this by adding: def state @file_state end to your model and then calling news.state.delete_files I''ve only just tried this in the console and it worked, but there may be some bad implications of exposing that variable or other problems. If some others want to help dig into this, that would be cool. jared -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---