diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index d0509e3..477c07f 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -21,7 +21,7 @@ class ArticlesController < ApplicationController def show raise AccessError unless @article.can_show? cuser - @article.read_by! cuser if cuser + cuser.mark_as_read(@article) if cuser # @article.record_view_count(request.remote_ip, cuser.nil?) end diff --git a/app/models/article.rb b/app/models/article.rb index 314793f..52ab126 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -69,7 +69,7 @@ class Article < ActiveRecord::Base after_destroy :remove_readings has_view_count - acts_as_reader + acts_as_readable acts_as_versioned non_versioned_columns << 'category_id' diff --git a/app/models/category.rb b/app/models/category.rb index 2bc42d3..ab8fbb1 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -48,7 +48,7 @@ class Category < ActiveRecord::Base has_many :gathers has_many :servers - acts_as_reader + acts_as_readable def to_s name diff --git a/app/models/forum.rb b/app/models/forum.rb index 72fd341..dc34308 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -34,7 +34,7 @@ class Forum < ActiveRecord::Base after_create :update_position - acts_as_reader + acts_as_readable def to_s self.title diff --git a/app/models/issue.rb b/app/models/issue.rb index a279781..887e3d7 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -35,10 +35,10 @@ class Issue < ActiveRecord::Base belongs_to :author, :class_name => "User" belongs_to :assigned, :class_name => "User" - scope :unread_by, - lambda { |user| { - :joins => "LEFT JOIN readings ON readable_type = 'Issue' AND readable_id = issues.id AND readings.user_id = #{user.id}", - :conditions => "readings.user_id IS NULL"} } + #scope :unread_by, + # lambda { |user| { + # :joins => "LEFT JOIN readings ON readable_type = 'Issue' AND readable_id = issues.id AND readings.user_id = #{user.id}", + # :conditions => "readings.user_id IS NULL"} } scope :with_status, -> (s) { where(status: s) } validates_length_of :title, :in => 1..50 @@ -49,7 +49,7 @@ class Issue < ActiveRecord::Base before_save :parse_text after_save :remove_readings - acts_as_reader + acts_as_readable def to_s title diff --git a/app/models/message.rb b/app/models/message.rb index c288b10..c91aeb2 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -24,12 +24,12 @@ class Message < ActiveRecord::Base validates_length_of :text, :in => 1..65000 scope :ordered, :order => "created_at DESC" - scope :read_by, - lambda { |user| {:include => :readings, :conditions => ["readings.user_id = ?", user.id]} } - scope :unread_by, - lambda { |user| { - :joins => "LEFT JOIN readings ON readable_type = 'Message' AND readable_id = messages.id AND readings.user_id = #{user.id}", - :conditions => "readings.user_id IS NULL"} } + #scope :read_by, + # lambda { |user| {:include => :readings, :conditions => ["readings.user_id = ?", user.id]} } + #scope :unread_by, + # lambda { |user| { + # :joins => "LEFT JOIN readings ON readable_type = 'Message' AND readable_id = messages.id AND readings.user_id = #{user.id}", + # :conditions => "readings.user_id IS NULL"} } belongs_to :sender, :polymorphic => true belongs_to :recipient, :polymorphic => true @@ -37,7 +37,7 @@ class Message < ActiveRecord::Base before_save :parse_text after_create :send_notifications - acts_as_reader + acts_as_readable def to_s title diff --git a/app/models/movie.rb b/app/models/movie.rb index bce92e4..d834d0e 100644 --- a/app/models/movie.rb +++ b/app/models/movie.rb @@ -62,7 +62,7 @@ class Movie < ActiveRecord::Base mount_uploader :picture, MovieUploader has_view_count - acts_as_reader + acts_as_readable def to_s file.to_s diff --git a/app/models/topic.rb b/app/models/topic.rb index ac2e1df..84dc60a 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -39,7 +39,7 @@ class Topic < ActiveRecord::Base after_create :make_post - acts_as_reader + acts_as_readable def self.recent_topics find_by_sql %q{ diff --git a/app/models/user.rb b/app/models/user.rb index 4ecc4aa..b530d7f 100755 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -119,6 +119,8 @@ class User < ActiveRecord::Base accepts_nested_attributes_for :profile + acts_as_reader + acts_as_versioned non_versioned_columns << 'firstname' non_versioned_columns << 'lastname' diff --git a/app/views/articles/index.html.erb b/app/views/articles/index.html.erb index b2c2ae7..06a2f8f 100644 --- a/app/views/articles/index.html.erb +++ b/app/views/articles/index.html.erb @@ -8,7 +8,7 @@ <% category.articles.nodrafts.ordered.each do |article| %>