authors can retire proposals now

This commit is contained in:
Juanjo Bazán
2016-04-22 14:42:49 +02:00
parent be011a10dc
commit 58a5e2a283
11 changed files with 174 additions and 10 deletions

View File

@@ -12,6 +12,8 @@ class Proposal < ActiveRecord::Base
acts_as_paranoid column: :hidden_at
include ActsAsParanoidAliases
RETIRE_OPTIONS = %w(duplicated started unfeasible done other)
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
belongs_to :geozone
has_many :comments, as: :commentable
@@ -26,6 +28,7 @@ class Proposal < ActiveRecord::Base
validates :description, length: { maximum: Proposal.description_max_length }
validates :question, length: { in: 10..Proposal.question_max_length }
validates :responsible_name, length: { in: 6..Proposal.responsible_name_max_length }
validates :retired_reason, inclusion: {in: RETIRE_OPTIONS, allow_nil: true}
validates :terms_of_service, acceptance: { allow_nil: false }, on: :create