lib/apimaster/generators/templates/app/models/example.rb.erb in apimaster-0.0.3 vs lib/apimaster/generators/templates/app/models/example.rb.erb in apimaster-0.0.4

- old
+ new

@@ -7,9 +7,19 @@ include Mongoid::Document field :title, type: String field :content, type: String - attr_options :title, accessor: [:list], required: [:post] - attr_options :content, accessor: [:get], required: [:post] + attr_options :title, accessor: [:get, :list], required: [:post], optional: [:patch] + attr_options :content, accessor: [:get], required: [:post], optional: [:patch] + + validates :title, length: { minimum: 2, maximum: 30 } + + class << self + + def get id + find id or raise MissingError.new(<%= name %>, :id) + end + + end end end