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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:04:23+00:00 2026-05-18T20:04:23+00:00

I just recently inherited a Rails application and am debating an architectural decision moving

  • 0

I just recently inherited a Rails application and am debating an architectural decision moving forward. Here’s a bit of background… Feedback appreciated.

There are, currently, 16 different ad types, all with a set of the same attributes, several with one or two additional attributes, and a couple with three or four.

Currently each ad type has a separate model and table with the respective columns, and a separate controller and views in a CMS too used for basic CRUD. The CMS takes advantage of inherited_resources, so that limits some of the duplication.

I wrote out the attribute set — there are 20 or so that cover all ad types. Certain ad types have associations — several has_many associations where the foreign key is stored on the associated table and a few belongs_to.

The ads have no real behavior. Specific ad types are simply displayed on various pages, so as long as I can determine if there is an ad of a specific type, we’re golden.

I am debating moving to a single model, table, and controller, but want to get as much input as possible from the stackoverflow community on whether or not this is 1) a good fit for the problem 2) any performance concerns 3) any potential programming bottlenecks I haven’t though of. Here is my thinking so far…


Assuming a route /:location/:ad_type/new (e.g. /homepage/ad_type_1/new):

The ad_controller would create @ad with ad_type set to params[:location] + params[:ad_type] and render the new view which would contain a series of conditionals for displaying the appropriate partials for the given ad_type. Submit would fire the create action creating the ad with the expected attributes defined for the ad type, one of which in this case would be ad_type = homepage_ad_type_1.

I’ve not thought as much about retrieving the data, but assuming the ad_type column is set correctly, I should be able to create an “of_type” scope that pulls records based on the ad_type column. Not sure if I’m missing something there.

Validations will vary based on the ad_type value.

I’m not entirely certain how many ads will exist at any given time, but I feel this could be addressed at a later time. Either by moving off some of the stale rows to an ad_archives table or similar.

Your thoughts are appreciated. Thanks.

  • 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-18T20:04:23+00:00Added an answer on May 18, 2026 at 8:04 pm

    I would probably use a single table model for this, but if it makes sense to use multiple controllers/views, you don’t have to restrict yourself to a single controller, and you can still query ads based on their type without using conditionals. Example:

    create_table :people do |t|
      t.string first_name
      t.string last_name
      # some other properties...
      t.string type
    end
    
    class Student < Person
    end
    
    class Teacher < Person
    end
    
    Person.all # shows all students and teachers
    Teacher.all # shows all teachers
    

    So it would be easy to make a Teachers controller and a Students controller, as well as a People controller.

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

Sidebar

Related Questions

I just recently inherited a Rails application and am debating an architectural decision moving
Here's my situation. I've just started a new job and I've inherited an application
I just recently started working with Qt 4.7.4 64-bit in order to make some
Recently I inherited a new ASP web application that merely allows customers to pay
I've recently inherited a internationalized and text-heavy Struts 1.1 web application. Many of the
Background: I've inherited a web application that is intended to create on-the-fly connections between
I recently inherited a simple PHP application built on Piwi ( http://www.piwiframework.de/default.html ). Has
Just recently I've installed the Qt libraries on my computer, and as a complete
Just recently I dove into the VideoLAN open source project. This was my first
So just recently, my async server code which relies on pthread_mutex_timedlock seem to have

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.