summaryrefslogtreecommitdiff
path: root/app/models/concerns/valid_attribute.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/concerns/valid_attribute.rb')
-rw-r--r--app/models/concerns/valid_attribute.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/concerns/valid_attribute.rb b/app/models/concerns/valid_attribute.rb
new file mode 100644
index 00000000000..8c35cea8d58
--- /dev/null
+++ b/app/models/concerns/valid_attribute.rb
@@ -0,0 +1,10 @@
+module ValidAttribute
+ extend ActiveSupport::Concern
+
+ # Checks whether an attribute has failed validation or not
+ #
+ # +attribute+ The symbolised name of the attribute i.e :name
+ def valid_attribute?(attribute)
+ self.errors.empty? || self.errors.messages[attribute].nil?
+ end
+end