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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:39:55+00:00 2026-06-03T14:39:55+00:00

In my Rails3 app, I am using ActiveRecord and Postgresql . Say I have

  • 0

In my Rails3 app, I am using ActiveRecord and Postgresql.

Say I have a model called Parts. The model has a small list of standard attributes such as price, quantity, etc.

However, Customer A might want to add LotNumber and CustomerB might want to add OriginalLocation.

How would I allow them to do that?

I thought about creating a PartsDetail model that allowed them to have a type.

class PartsDetail < ActiveRecord::Base
    attr_accessible :type, :value, :part_id
    belongs_to :parts
end

So that “type” could be “LotNumber”, etc.

But I’m not quite sure how that would work in my associations and querying.

Any ideas?

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-06-03T14:39:58+00:00Added an answer on June 3, 2026 at 2:39 pm

    Since you’re using PostgreSQL, you could use hstore to store arbitrary hashes in database columns:

    This module implements the hstore data type for storing sets of key/value pairs within a single PostgreSQL value. This can be useful in various scenarios, such as rows with many attributes that are rarely examined, or semi-structured data. Keys and values are simply text strings.

    There’s even a gem for adding hstore support to ActiveRecord:

    https://github.com/softa/activerecord-postgres-hstore

    Then you could create an hstore column called, say, client_specific and look inside it with things like:

    M.where("client_specific -> 'likes' = 'pancakes'")
    M.where("client_specific @> 'likes=>pancakes'")
    

    to see which clients have noted that they like pancakes.

    You might want to store a list of customer-specific fields somewhere with the customer record to make the UI side of things easier to deal with but that’s pretty simple to do.

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

Sidebar

Related Questions

I'm currently using the ActiveRecord-based session store for my Rails app and I have
I have a Rails app using a Postgres database with a table called geolite_blocks.
I have already implemented some AJAX pagination in my Rails app by using the
I have managed to run a basic rails app1 on App Engine using: http://gist.github.com/268192
I'm on Rails 3.1.1 and I have noticed my app has become exceedingly slow
In my rails app, i am using a legacy database. class Expression < ActiveRecord::Base
I have a simple Rails 3.1 CRUD app built using Oracle running on JRuby.
Background I'm using the acts_as_list gem in a rails app my posts table has
Am planning on using declarative authorization in a Rails 3 app. I have the
Am planning on using declarative authorization in a Rails 3 app. I have the

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.