Method: Unread::Readable::Scopes#join_read_marks

Defined in:
lib/unread/readable_scopes.rb

#join_read_marks(reader) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/unread/readable_scopes.rb', line 4

def join_read_marks(reader)
  assert_reader(reader)

  joins "LEFT JOIN #{ReadMark.quoted_table_name}
          ON #{ReadMark.quoted_table_name}.readable_type  = '#{readable_parent.name}'
         AND #{ReadMark.quoted_table_name}.readable_id    = #{quoted_table_name}.#{quoted_primary_key}
         AND #{ReadMark.quoted_table_name}.reader_id      = #{quoted(reader.id)}
         AND #{ReadMark.quoted_table_name}.reader_type    = #{quoted(reader.class.base_class.name)}
         AND #{ReadMark.quoted_table_name}.timestamp     >= #{quoted_table_name}.#{connection.quote_column_name(readable_options[:on])}"
end