cirandas.net

ref: master

plugins/comment_paragraph/lib/ext/comment.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
require_dependency 'comment'

class Comment

  scope :without_paragraph, -> { where paragraph_uuid: nil }

  settings_items :comment_paragraph_selected_area, :type => :string
  settings_items :comment_paragraph_selected_content, :type => :string

  scope :in_paragraph, -> paragraph_uuid {
    where 'paragraph_uuid = ?', paragraph_uuid
  }

  attr_accessible :paragraph_uuid, :comment_paragraph_selected_area, :id, :comment_paragraph_selected_content

  before_validation do |comment|
    comment.comment_paragraph_selected_area = nil if comment.comment_paragraph_selected_area.blank?
    comment.comment_paragraph_selected_content = nil if comment_paragraph_selected_content.blank?
  end

end