I'm storing the multiple ids as string in another table. Now I need to join id's table and query the joined table
Model
user.rb
#columns
id:
name: string
# associations
has_one :user_store
store.rb
#columns
id:
name: string
user_store.rb
#columns
id: integer
user_id: integer
store_ids: string
#association
belongs_to :user
I store the multiple store ids in user_store's store_ids column
example UserStore.first =>
#<UserStore:0x00005636e9ae7358
id: 1,
user_id: 1,
stores: "31, 32, 33, 34, 35",
created_at: Wed, 25 Aug 2021 19:24:37.292280000 UTC +00:00,
updated_at: Wed, 25 Aug 2021 19:24:37.292280000 UTC +00:00>
How do I query to Store table from UserStore?
Ruby - 3.0.1
Rails - 6.1.3.2
Postgres - 10