reason_for_rejection is required if marked as rejected

This commit is contained in:
Taylor Griffin
2015-02-03 13:18:59 +11:00
parent 2f67ffd2f8
commit 47dc94f820

View File

@@ -35,6 +35,8 @@ class Crop < ActiveRecord::Base
},
:if => :approved?
validates :reason_for_rejection, :presence => true, :if => :rejected?
def to_s
return name
end
@@ -114,6 +116,10 @@ class Crop < ActiveRecord::Base
approval_status == "approved"
end
def rejected?
approval_status == "rejected"
end
# Crop.interesting
# returns a list of interesting crops, for use on the homepage etc
def Crop.interesting