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 8839873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:20:07+00:00 2026-06-14T10:20:07+00:00

I am using this file upload example to upload some files in the database.

  • 0

I am using this file upload example to upload some files in the database. I have a rruby.rb with r-script in it which makes statistical analysis of the file(name it A) , and as a result it saves a plot in the directory where the file A is situated.
What I need is to extract the file from the database, do analysis and save the plot back into a database.
Where should I place the code of rruby.rb?In uploads_controller, upload.rb?

  • 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-06-14T10:20:08+00:00Added an answer on June 14, 2026 at 10:20 am

    I would keep the rruby.rb file separate and use it as is. But where to place that file?

    There are two equally valid options. Either you place it in lib folder, or place it in the models folder.

    I would place it in the lib folder if I consider more generic and code that I happen to need. Code in lib is code that eventually could be turned into a gem. It is code that I consider completely unrelated to any business code or models.

    If the code is strongly related to my business domain and other models.

    So in your case I would place the rruby file in the lib folder since (if I understand correctly) it contains an pretty isolated procedure, no dependency on the rest of the code, just needs a file as input, and will generate a file as output.

    Another advantage of keeping rruby code separate is that you can test it in isolation as well.

    Hope this helps.

    [EDIT: added example implementation]

    I presume your rruby is a simple script, so you wrap it in a module, since it performs statistical analysis I call it Statistical, but you should give it a more appropriate name

    So in lib/statistical.rb write

    module Statistical
    
      def self.do_analysis(file_to_analyse)
        # .. do a lot of stuff and return a result-file
      end
    end
    

    Then in your uploadscontroller or uploads model, you do something like

    result_file = Statistical.do_analysis(uploaded_file)
    

    Normally all files inside the lib are automatically added to rails load-path, so this is all you need to do.

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

Sidebar

Related Questions

I'm using blueimp JQuery file upload script to fancy the uploading of files. You
I used this example (http://reecon.wordpress.com/2010/04/25/uploading-files-to-http-server-using-post-android-sdk/) to upload file from android device to server, it
I am using the jQuery-File-Upload widget (although I believe this question can generalize to
I got this traceback when trying to upload a file using put_file (source code
I am trying to upload a pdf file using webservice api. But this api
Using this file as source, I have a situation where I need to retrieve
I'm using this code to upload files asynchronously to my web server. WebClient fileUploader
I'm using uploadify (a jQuery uploading) script, which has basically a PHP file at
I have a asp.net website which is supposed to upload files to a handler
For some reason, we have a script that creates batch files to XCOPY our

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.