This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder