Sha256: d3f9b33442c26eedf0e2d2bfac3c97b5c4d16b245d7403ffc9bb4adb2f57e2dc

Contents?: true

Size: 268 Bytes

Versions: 3

Compression:

Stored size: 268 Bytes

Contents

module PersonalBlog
  class Comment < ActiveRecord::Base
    before_create :set_anonymous_default
    validates :text, presence: true

    private 
    def set_anonymous_default
      if self.author.empty?
        self.author = 'Anonymous'
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
personal_blog-0.0.3 app/models/personal_blog/comment.rb
personal_blog-0.0.2 app/models/personal_blog/comment.rb
personal_blog-0.0.1 app/models/personal_blog/comment.rb