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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:42:00+00:00 2026-05-20T17:42:00+00:00

I’ve got a Product model, a Statuses model and a Productstatuses model. Product has_many

  • 0

I’ve got a Product model, a Statuses model and a Productstatuses model.

Product has_many :productstatuses, :dependent => :destroy
Product has_many :statuses, :through => :productstatuses

Status has_many :productstatuses
Status has_many :products, :through => :productstatuses

Productstatus belongs_to :product
Productstatus belongs_to :status

I’m using the statuses in two ways.

One, to show progression as a product is making its way through our system (statuses bookmark, processing, approved. Once a product has a status of approved, it can’t move backward in the system (so that I don’t create a public 404). A product must have one of these three at all times to be valid.

I also use the statuses for different “flags” on the products:

  • retired when a product is no longer available (this product will also always have approved status; approved == publically indexable in our sitemap, but retired removes it from everywhere on our site (index, archives, etc) without 404’ing its permalink)
  • pre-sale when a product is not available yet (could have any of the three above)
  • needs-images (could have any of the three)

My question is a bit of a two-parter:

  1. Should I have just made the “flags” statuses booleans on the Product model? I ask because:

  2. How do I write a scope that says approved but not retired? Or approved but not retired and not needs-images?

With a boolean, I can just have a scope like
scope :not_foo where(:foo = false) and chain those all up. I’m drawing a blank on the best way to do the same with the above setup. I thought the has_many :through setup was the way to go (the flags as booleans just seemed like a lot of excess falses in my database) but database structure/planning is not my strong suit.

  • 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-20T17:42:01+00:00Added an answer on May 20, 2026 at 5:42 pm

    I would suggest using state machine for the product flow pre-sale, approved and retired and a boolean flag for needs-images for indicating additional state which is out of the flow.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6

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.