Add image description to budget investments

This commit is contained in:
Senén Rodero Rodríguez
2017-06-14 14:43:30 +02:00
parent 00a8f42797
commit c399692109
5 changed files with 57 additions and 8 deletions

View File

@@ -41,6 +41,8 @@ class Budget
validates :description, length: { maximum: Budget::Investment.description_max_length }
validates :terms_of_service, acceptance: { allow_nil: false }, on: :create
validates_attachment :image, content_type: { content_type: ["image/jpeg"] }
validates :image_description, presence: true, if: -> { image.present? }
validates :image_description, length: { in: 4..Budget::Investment.title_max_length }, if: -> { image.present? }
scope :sort_by_confidence_score, -> { reorder(confidence_score: :desc, id: :desc) }
scope :sort_by_ballots, -> { reorder(ballot_lines_count: :desc, id: :desc) }