I need to display the Specialization that are not selected. User has_and_belongs_to_many specializations and Specialization has_and_belongs_to_many user. Is there any possible to display the specializations that are not selected by the current user.
class User < ApplicationRecord
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :doorkeeper
belongs_to :user_type, optional: true
has_many :comments, dependent: :destroy
has_many :lessons, foreign_key: :created_by
has_many :qualifications, dependent: :destroy
has_many :videos, dependent: :destroy
has_and_belongs_to_many :specializations
validates_uniqueness_of :email
And Specialization model is
class Specialization < ApplicationRecord
has_and_belongs_to_many :users
end
And join table is
class JoinTableUserSpecialization < ActiveRecord::Migration[5.0]
def change
create_join_table :users, :specializations do |t|
t.index [:user_id, :specialization_id], name: "index_users_on_specialization_id"
t.index [:specialization_id, :user_id], name: "index_specializations_on_user_id"
end
end
end
Specialization controller is
def suggest
@specializations = Specialization.all
end