Sha256: 033204a51fed82d9244193ab42a31f4faf6b4e703b19d448fce310c352b2eac4

Contents?: true

Size: 676 Bytes

Versions: 50

Compression:

Stored size: 676 Bytes

Contents

# encoding: utf-8
class Note
  include Mongoid::Document
  # jinda begin
  include Mongoid::Timestamps
  include Mongoid::Attributes::Dynamic
  field :title, :type => String
  field :body, :type => String
  belongs_to :user
  before_validation :ensure_title_has_a_value 
  validates :title, length: { maximum: (MAX_TITLE_LENGTH = 30), message: "Must be less   than 30 characters" }, presence: true
  validates :body, length: { maximum: (MAX_BODY_LENGTH = 1000), message: "Must be less   than 1000 characters"} 
  private
  def ensure_title_has_a_value
    if title.blank?
      self.title = body[0..(MAX_TITLE_LENGTH-1)] unless body.blank?
    end
  end
  

  # jinda end
end

Version data entries

50 entries across 47 versions & 4 rubygems

Version Path
jinda-0.8.0 test/dummy/app/models/note.rb
jinda-0.8.0 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.7.4 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.7.4 test/dummy/app/models/note.rb
jinda-0.7.7.3 test/dummy/app/models/note.rb
jinda-0.7.7.3 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.7.2 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.7.1 lib/generators/jinda/templates/app/models/note.rb
jinda_mind-1.0.0 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.7 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.6 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.5.5 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.5.4 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.5.3 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.5.2 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.5.0 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.3 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.2 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.1 lib/generators/jinda/templates/app/models/note.rb
jinda-0.7.0.4 lib/generators/jinda/templates/app/models/note.rb