Skip to content

Instantly share code, notes, and snippets.

module Hobo
module Scopes
class ScopeBuilder
def exists_sql_condition(reflection, any=false)
owner = @klass
owner_primary_key = "#{owner.table_name}.#{owner.primary_key}"
if reflection.options[:through]
class UserSession
def viewable_posts
# By using Post.scoped({}) rather than Post.all, you get a named scope proxy back,
# meaning that you can chain other scopes onto it
# and that the query is not executed until necessary.
admin? ? Post.scoped({}) : Post.published
end
end
class User