Users model migration I have a model Users that each instance have 3 features. It was alright until I wanted to tell if this instance can do the 1st feature, the 3rd or all.

I did a migration:

class AddStatusFeaturesToUsers &lt; ActiveRecord::Migration
  def change
    add_column :users, :status_feature_a, :boolean
    add_column :users, :status_feature_b, :boolean
    add_column :users, :status_feature_c, :boolean
  end
end


Is there a better way for doing this?
If your user and features model can have a many-to-many relationship, then you can use the following example:


  A has_and_belongs_to_many association creates a direct many-to-many
  connection with another model, with no intervening model


class CreateUsersAndStatusFeatures &lt; ActiveRecord::Migration
  def change
    create_table :status_features do |t|
      t.string :name
      t.timestamps null: false
    end
    # Do not create users table if you already have.
    create_table :users do |t|
      t.string :name
      t.timestamps null: false
    end
    create_table :users_status_features, id: false do |t|
      t.belongs_to :user, index: true
      t.belongs_to :status_feature, index: true
    end
  end
end

class User &lt; ActiveRecord::Base
  has_and_belongs_to_many :status_features
end
class StatusFeature &lt; ActiveRecord::Base
  has_and_belongs_to_many :users
end


If you want to know in detail, go to this link.