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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:25:22+00:00 2026-06-01T09:25:22+00:00

I am trying to refactor a half finished project. Original developer has left. In

  • 0

I am trying to refactor a half finished project. Original developer has left. In his model design, a separate “period” model is used. So a discount object has a usable period and event can have a period.

The periods table:

  create_table "periods", :force => true do |t|
    t.integer  "owner_id"
    t.string   "owner_type"
    t.datetime "begin"
    t.datetime "end"
    t.datetime "created_at",                               :null => false
    t.datetime "updated_at",                               :null => false
  end

I am starting to feel difficult writing listing queries based on dates. I need to join the period table and sort on that end date field.

What I want to ask is: what are the pros/cons of this approach? I am feeling that moving those back to the belonging models makes more sense.

  • 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-01T09:25:24+00:00Added an answer on June 1, 2026 at 9:25 am

    Making a period table is not necessarily a strange practice: As long as that kind of information is delivered to the project developer’s heir.

    And in a case where you would want to know about everything that happened in a given time period, say June, that devision of tables makes perfect sense.

    So my point is that I guess it’s about communication and needs. If you don’t need that functionality anymore, I suggest a migration that adds two new columns to all polymorphic tables related to the periods, begins_at and ends_at and then migrates all the data from the periods table into those respect columns.

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

Sidebar

Related Questions

trying to refactor code to provide clean association A GAME has a HOME_TEAM and
I'm trying to refactor a large, old project and one thing I've noticed is
I'm trying to refactor an old web service project using new structure (with Maven)
I am trying to refactor old PHP project, and this project does not access
I am trying to refactor a solution to bring on board another project. I
I'm trying to analyze/refactor/rewrite a complex PHP site. While I can work with separate
Im currently trying to refactor a project(asp.net mvc) that doesnt have any separation at
I've got a big Javascript project that I'm trying to refactor into pseudo-classes: jsFiddle:
I'm trying to refactor my sinatra code to separate my main file into separate
Trying to refactor some code that has gotten really slow recently and I came

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.