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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:44:01+00:00 2026-06-13T06:44:01+00:00

i have im my rails app model which has few options (no more than

  • 0

i have im my rails app model which has few options (no more than 10 i think).
Something like Product – Category, where product can be part of 1 or many categories.
But i think i have too few categories to engage fully fledged many-to-many construct.
Moreover the list of categroies is predefined and will almost never change.

I think from sql side this could look like string field categories with such content:"Fruits|Vegetables|..."

Maybe someone know preexisting gem for such functionality, or maybe it is no real advantage doing so and i should choose standart many-to-many ?

I checked acts-as-taggable-on plugin, but it is i think fits not very well for this task.

Enum gems like enumerize i think fit just best, but they are allow only single single value to be choosen.

  • 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-13T06:44:03+00:00Added an answer on June 13, 2026 at 6:44 am

    Currently came out with following combination:

    This gem:
    https://github.com/pboling/flag_shih_tzu

    In model:

    class Product < ActiveRecord::Base
      KINDS =  { 1 => :fruit, 2 => :vegetable }
      include FlagShihTzu
      attr_accessible *KINDS.values
      as_flags KINDS
    

    Then in view (haml):

        =form_for [@product] do |f|
          -Product::KINDS.each do |k, v|
            =f.check_box v
            =f.label v
    

    UPDATE:

    Yet another gem adressing this problem: https://github.com/joelmoss/bitmask_attributes

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

Sidebar

Related Questions

In a Rails 3.2 app I have a model Project, which has many Tasks.
I have a simple rails app with a model Task , which has 10
In my Rails app, I have a model Page which represents one HTML article
I have a rails app (rails 3.1.3) that has a shopping cart model. I
I seem to have broken validates_confirmation_of in my rails app. My model looks like
I'm using active admin for my rails app. I have a customer model which
I'm writing a Rails app in which I have two models: a Machine model
I have a Rails app which has 2 databases. Legacy DB with table called
I have a rails 3 app with paperclip. The model looks a little like:
My rails app has a simple model Links which tracks all the Urls associated

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.