File: post.rb

package info (click to toggle)
ruby-client-side-validations 3.2.6%2Bgh-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 672 kB
  • ctags: 510
  • sloc: ruby: 2,959; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 565 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Post
  extend  ActiveModel::Naming
  extend  ActiveModel::Translation
  include ActiveModel::Validations
  include ActiveModel::Conversion

  attr_accessor :title, :author_name, :body, :secret, :written_on, :cost
  validates :cost, :body, :presence => true
  validates :body, :length => { :minimum => 200 }

  def initialize(params={})
    params.each do |attr, value|
      self.public_send("#{attr}=", value)
    end if params
  end

  def persisted?
    false
  end

  attr_accessor :comments, :comment_ids
  def comments_attributes=(attributes); end
end