Skip to content

Instantly share code, notes, and snippets.

@rbishop
Last active December 12, 2015 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbishop/4773501 to your computer and use it in GitHub Desktop.
Save rbishop/4773501 to your computer and use it in GitHub Desktop.
Rails.cache.fetch :group_id => group.id, :goal_id => self.id do
Post.find_by_sql(
"#{Post.where(:attachment_type => 'UserGoalLog').where(Post.arel_table[:attachment_id].in(user_goal_logs.collect(&:id))).to_sql}
UNION
#{Post.where(:attachment_type => 'UserGoal').where(Post.arel_table[:attachment_id].in(user_goals.collect(&:id))).to_sql}"
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment