i have module returns timesheet records. when there scope parameter provided items method scopes timesheets returns timesheets. how can use result of query in query? using team_users in super.where(user_id: team_users) query.
module collections class timesheetcollection < collection module teamscope def items if params[:scope].present? team_users = user.from_team(@manager) super.where(user_id: team_users) else super end end end attr_reader :ability, :params def initialize(ability, params, manager) @ability = ability @params = params @manager = manager extend teamscope end def items timesheet.unscoped end def paginated extend pagination self end end end
for active record can pass in array of ids/values. query try this:
team_users = user.from_team(@manager) super.where(user_id: team_users.collect{|u| u.id})
Comments
Post a Comment