Forum: Ruby on Rails How do I tell roo to open a paperclip attachment after uploaded to later processing?

5a41028798f4e263c2d0692f5b1847ec?d=identicon&s=25 Monserrat Foster (Guest)
on 2013-10-07 16:14
(Received via mailing list)
Hello, I'm new to ruby and rails... I was planning to use the
spreadsheet
gem to open the files but it doesn't support xlsx.
I saw this as an example on how to do the same using paperclip

@workbook = Spreadsheet.open(MyFile.first.attachment.to_file)

I imagine with roo would be something like

# In this example the model MyFile has_attached_file :attachment

@workbook =  Roo::Excelx.new(MyFile.first.attachment.to_file)

**Like I said I'm new to Ruby and Rails, so I don't know what's "first",
I assume it refers to the first record (the lastest) on the MyFile
corresponding Table**

Is this the right way to do it? I find the use of "new" confusing,
although it says  loads an Excel Spreadsheet for Excel .xlsx files I
think it's creating a new one instead of loading the attachment. Thank
you for your guidance in advance.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.