I've got a very simple file upload for a text file using paperclip.
What I want to do is to get the first line of the text file and turn it into a hash I can search against in a database.
I don't think it makes much sense to save the file, then retrieve it, create the hash, and then save it again.
I can't seem to figure out how to get the text of the attached file before saving.
my controller is fairly simple at the moment
def create @upload = Upload.new(params[:upload]) @upload.user_id=current_user.id #get the first line of the uploaded file if @upload.save redirect_to @upload, :notice =>'Successfully uploaded file." else render :action => 'new' end end
Going through the documentation, I've seen that paperclip has a to_tempfile, which I assume I can read into a string, but i can't seem to find anywhere that shows me how to do that.