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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:21:53+00:00 2026-05-19T14:21:53+00:00

Given I have a model house and it lives through several states, something like

  • 0

Given I have a model house and it lives through several states, something like this:
Dreaming —> Planning —> Building —> Living —> Tearing down

If I would want to retrieve let’s say ten houses from the databse and order them by the state field, I’d get first all houses in the Building state, then Dreaming, then Living, …

Is it possible to fetch all houses from the database and order them by the state in the order intended before retrieving them? Meaning, first all houses in the Dreaming state, then Planning, etc. E.g. by providing the order in an array for comparison of sorts.

I’d like to avoid doing this in Ruby after having fetched all entries as well as I wouldn’t want to use IDs for the states.

After reading up on enum implementations, I guess, if I can make it work, I’ll try to combine the enum column plugin with the state_machine plugin to achieve what I’m after. If anyone has done something like this before (especially the combination under Rails 3), I’d be grateful for input!

  • 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-19T14:21:53+00:00Added an answer on May 19, 2026 at 2:21 pm

    Here’s some information on how to use SQL ENUMs in rails — they’re relatively database portable and do roughly what you want — http://www.snowgiraffe.com/tech/311/enumeration-columns-with-rails/

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

Sidebar

Related Questions

I have a model like this: Client - which has many Locations - which
Given I have a Model object like ... public class MyModel { public int
Given I have an Artifact model and a User model: I would like to
I have a model like this: class Person(models.Model,Subject): name = .. The class Subject
Given two model classes, Foo and Bar , I want Foo to have 3
I have a script. I would like to give this script a quiet mode
To provide an activity log in my SQLAlchemy-based app, I have a model like
Given you have a domain model with a simple parent / child relationship, and
Suppose I have this model: public class ViewModel { [Required] public string UserInput {
Given I have a model/table with appointments, saved as a date. I want to

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.