implemented forum post controller
This commit is contained in:
@@ -7,7 +7,7 @@ class ForumPost < ActiveRecord::Base
|
||||
after_save :update_topic_updated_at
|
||||
validates_presence_of :body, :creator_id
|
||||
scope :body_matches, lambda {|body| where(["text_index @@ plainto_tsquery(?)", body])}
|
||||
search_methods :body_matches
|
||||
search_method :body_matches
|
||||
|
||||
def editable_by?(user)
|
||||
creator_id == user.id || user.is_moderator?
|
||||
|
||||
@@ -186,7 +186,8 @@ class User < ActiveRecord::Base
|
||||
return false unless is_privileged?
|
||||
newest_topic = ForumPost.first(:order => "updated_at desc", :select => "updated_at")
|
||||
return false if newest_topic.nil?
|
||||
return newest_topic.updated_at > user.last_forum_read_at
|
||||
return true if last_forum_read_at.nil?
|
||||
return newest_topic.updated_at > last_forum_read_at
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user