0

I have an advertising site running where users can post "headlines" and "sublines" in a form. I want to take this thing further.

Users should upload their .txt or .rtf file, comma seperated, so that it's created in my database.

Let's say this is the users rtf or whatever:

This is my headline; This is my subline;
This is my second headline; This is my second subline;

How can I achieve that this is parsed and written to my database? No csv or whatever. Just a simple text file.

Where should I put this form?

How can I parse it?

The Guy with The Hat
  • 10,836
  • 8
  • 57
  • 75
  • 1
    You could read and save the file as a TMP. Once you have it, read it in mem, parse it with regexs and store. Once you're done, you can ditch it. Here's a similar question without an accepted answer http://stackoverflow.com/questions/10426135/how-to-upload-a-text-file-and-parse-contents-into-database-in-ror – lsaffie Mar 09 '14 at 01:03

1 Answers1

0

You might want to look at using Paperclip to upload the file & then you'll be able to access its data using this answer: How do you access the raw content of a file uploaded with Paperclip / Ruby on Rails?

Community
  • 1
  • 1
Richard Peck
  • 76,116
  • 9
  • 93
  • 147