- unique_code belongs_to :community
- unique_code belongs_to :user
- user has_many :unique_codes
- community has_many :unique_codes
I want to fetch all the
unique_codes just like this below
@unique_codes = @user.unique_codes @unique_codes_count = unique_codes.count
However, there's sometimes community which is already deleted. Assume the user had 10 unique_codes, then one community is already deleted.
10 but I want
9 which is the number of unique_codes of active communities.
How can I?