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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:19:31+00:00 2026-05-24T09:19:31+00:00

I’ve built a Rails app that’s pretty simple… you send a request to a

  • 0

I’ve built a Rails app that’s pretty simple… you send a request to a certain web page, it automatically generates a report and saves it to a file locally on the server. The report that generates is by default created for the current day. What I would like to do is allow the user to enter the date in the url which they would like to have the report generated for turning my little one trick pony into something a little more useful.

As it stands right now I’ve built all of the useful report generation code into the index action of the the home controller but can’t help but feel that it really belongs in a model instead of the controller, but I’m not quite sure how to make that transition.

Any advice from you seasoned rails vets would be greatly appreciated.

Thanks.

The code in my index action….
Basically the index action get’s called and my program figures out what day it is, then uses the date to make a request to another API which then returns the necessary information in the form of an object. I then simply go through the object, gather the info I need and generate a text file with that information. The view for the home controller just prints a message saying the report has been generated and provides the path to it.

I would like to stress that I would like to use a url like mysite.com/report/20110803 to provide my controller with the information about the date the report should be run for.

  • 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-24T09:19:31+00:00Added an answer on May 24, 2026 at 9:19 am

    You are thinking correctly that this code belongs to a model. Ideally, the Report model. A controller should generally just feed the view with instance variables, handle flash messages and so on. The logic should be in the model.

    That said, i would do it like this: Create a model method that generates the report you want. Then, execute that method in the controller and get back the report you want based on the timestamp that is passed into the model method.

    Then, would have this in the controller:

    redirect_to new_report_url, :stamp => the_stamp_value
    

    I think you get the idea. You just need to have a simple route that expects a stamp value and you are good to go 🙂

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Does anyone know how can I replace this 2 symbol below from the string

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.