I'm confused about singular vs plural forms in active record association queries.
Here are my two models:
class Biography < ActiveRecord::Base
has_one :lifestyle, dependent: :destroy
end
class Lifestyle < ActiveRecord::Base
belongs_to :biography
end
And I've a search form, through which I'm finding lifestyles of a biography where diet is of a certain kind.
query = Biography
query = query.joins(:lifestyle).where(lifestyles: { diet: params[:diet_ids] }) if params[:diet_ids]
result = query.all
I can understand why joins(:lifestyle) is singular because it is a one to one relationship. But why is lifestyles in where(lifestyles...) plural? Is it because the table name is plural? But I've seen examples on the web where it is not plural as in this link stackoverflow link