You can easily achieve that with the help of the has_many :sm, through: :relation
:
class User < ActiveRecord::Base
has_many :user_city_relations
has_many :preferred_cities, through: :user_city_relations, source: :city
class City < ActiveRecord::Base
has_many :user_city_relations
has_many :users, through: :user_city_relations
class UserCityRelation < ActiveRecord::Base
belongs_to :user
belongs_to :city
validates :user_id, :city_id, presence: true
And use it like this:
user.preferred_cities
It is very similar to a has_and_belongs_to_many
but here you define the join model by yourself, which gives you more control about this relation. It is also more flexible (for new features in the futures, like active/inactive preferred Cities, etc.)