You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class User < ApplicationRecord
has_many :active_projects, -> { with_state(:active) }, class_name: Project
end
class Project < ApplicationRecord
belongs_to :user
state_machine :state, initial: :pending do
state :active
end
end
And if I do the following query
> Project.joins(user: :active_projects).to_sql
=> "SELECT `projects`.* FROM `projects` INNER JOIN `users` ON `users`.`id` = `projects`.`user_id` INNER JOIN `projects` `active_projects_users` ON `active_projects_users`.`user_id` = `users`.`id` AND (`projects`.`state` IN ('active'))"
The text was updated successfully, but these errors were encountered:
say if I have the following associations
And if I do the following query
The text was updated successfully, but these errors were encountered: