title: Are scopes in rails class or instance methods?
body: <p>This is a question from a rails noob trying to understand concerns and scopes.</p>
  
  <p>I always thought scopes were class methods in rails but then the other day I saw <a href="http://37signals.com/svn/posts/3372-put-chubby-models-on-a-diet-with-concerns" rel="nofollow">this code from DHH</a>:</p>
  
  <pre><code>module Visible
    extend ActiveSupport::Concern`
  
    module ClassMethods
      def visible_to(person)
        where \
          "(#{table_name}.bucket_id IN (?) AND
            #{table_name}.bucket_type = 'Project') OR
           (#{table_name}.bucket_id IN (?) AND
            #{table_name}.bucket_type = 'Calendar')",
          person.projects.pluck('projects.id'), 
          calendar_scope.pluck('calendars.id')
      end
    end
  end
  </code></pre>
  
  <p>So the way the <code>visible</code> method is used is like so:</p>
  
  <p><code>current_account.posts.visible_to(current_user)</code></p>
  
  <p>This is what is confusing me. <code>Self</code> here is a collection of posts so we are acting on instances whereas the visible method seems to be meant to be used as a class method. Isn't david trying to call a class method as a dynamic scope? Could someone please clarify?</p>