Noosfero/noosfero

View on GitHub
plugins/comment_paragraph/lib/ext/comment.rb

Summary

Maintainability
A
0 mins
Test Coverage
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