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

  • SEARCH
  • Home
  • 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 8777663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:19:47+00:00 2026-06-13T19:19:47+00:00

I have many models which I use to obtain data and generate a report.

  • 0

I have many models which I use to obtain data and generate a report.

The report doesn’t need to be stored, i.e. it’s not an active record.

But certainly there’s like 80 lines of code which generate the data for the report.

Where should I put those lines?

They are currently in the controller but since controller should be thin, I’m not sure if that’s the best place.

  • 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-13T19:19:48+00:00Added an answer on June 13, 2026 at 7:19 pm

    I would create a directory in app called reports, and put all of my reports in there.

    Everything in the app directory in rails can be found as long as the filename and class follow the normal convention.

    For example, if you have the following in app/reports/example_report.rb:

    class ExampleReport
      def initialize
        ...
      end
    end
    

    You will be able to use it from your controllers as such:

    class SomethingController < ApplicationController
      def something
        example = ExampleReport.new
        ...
      end
    end
    

    Reports that rely on models are considered part of your application’s domain, which is why I recommend the app directory. The ease of adding subdirectories in app means that you can maintain a logical separation of the different roles in your application. It shouldn’t be hard to guess where the implementation for something is. Controllers are in app/controllers, models are in app/models, so it follows that reports are in app/reports. And for example, if you were to add generic service classes to your app, they could go in app/services.

    In contrast, they do not belong in lib, because they cannot function in a generic fashion. To further this point, only code that you could envision being used in any rails project belongs in the lib directory.

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

Sidebar

Related Questions

Suppose I have a Book model, which contains many Page models. The routing for
My application has many models, many of which contain percentage data. These are represented
I am writing an application where many (but not all) ActiveRecord models have a
I have an Entry model which has many Tag s. Tag s are added
I have a simple User model which is associated to many Town objects using
I have a model Task which will HABTM many TaskTargets. When it comes to
In the Rails application I’m currently developing I have many request models. We are
I'm using rails 3.2. I have many to many type of models. Is there
I have models Product and Category . Category can have many products. ( Product
I have a couple of models which share a has_many associations, named scopes and

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.