Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3790406
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:18:34+00:00 2026-05-19T12:18:34+00:00

I am using paperclip to attach an excel file to a mode. The purpose

  • 0

I am using paperclip to attach an excel file to a mode.

The purpose is to import the data from the excel file to the database.

Model: Import
has_attached_file: spreadsheet

For the import process, I want to access the file in my model as following.

path = "#{Rails.root}/public/#{spreadsheet.url}"    

This doesn’t work. I guess because the url has the timestamp at the end.

In general what is the best way to access the attachments on server side ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:18:34+00:00Added an answer on May 19, 2026 at 12:18 pm

    I think you’re looking for the to_file method. You should be able to do something like this:

    excel_file = self.spreadsheet.to_file
    

    which will either return the uploaded file from the server (if you’re using s3 or remote storage), or if it has been assigned to the model but not actually stored yet (if you haven’t called model.save since it was uploaded), it returns the temp file stored on disk.

    From there you should be able to use an excel gem or library to parse the contents.

    Alternatively, you can use spreadsheet.url(nil, false) – the second parameter denotes whether or not to append a timestamp.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Paperclip with a Ruby on Rails to attach assets to a model,
I have a model, Thing, that has a has_many with ThingPhoto, using Paperclip to
I am using the paperclip gem to attach files to models. When you upload
I'm using Paperclip to allow users to attach things, and then I'm sending an
I'm using paperclip for attachments in my application. I'm writing an import script for
I'm using paperclip to upload a pdf. Once the file is uploaded I need
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
I am using Paperclip to upload numerous files to S3 (on production) and locally
I'm using paperclip by thoughtbot for attachments to models and everything works fine on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.