Allow error messages without attribute name. Improve enterprise relationship error message.

This commit is contained in:
Rohan Mitchell
2014-05-16 11:25:51 +10:00
parent 9b2a80c6b5
commit e40843bccb
3 changed files with 9 additions and 1 deletions

View File

@@ -35,6 +35,7 @@ gem 'geocoder'
gem 'gmaps4rails'
gem 'spinjs-rails'
gem 'rack-ssl', :require => 'rack/ssl'
gem 'custom_error_message', :github => 'jeremydurham/custom-err-msg'
gem 'foreigner'
gem 'immigrant'

View File

@@ -6,6 +6,12 @@ GIT
actionpack (~> 3.0)
activemodel (~> 3.0)
GIT
remote: git://github.com/jeremydurham/custom-err-msg.git
revision: 3a8ec9dddc7a5b0aab7c69a6060596de300c68f4
specs:
custom_error_message (1.1.1)
GIT
remote: git://github.com/openfoodfoundation/spree.git
revision: da651b40f5c6cdd32e00b060729eb9aefd4f615f
@@ -492,6 +498,7 @@ DEPENDENCIES
coffee-rails (~> 3.2.1)
comfortable_mexican_sofa
compass-rails
custom_error_message!
database_cleaner (= 0.7.1)
db2fog
debugger-linecache

View File

@@ -3,7 +3,7 @@ class EnterpriseRelationship < ActiveRecord::Base
belongs_to :child, class_name: 'Enterprise'
validates_presence_of :parent_id, :child_id
validates_uniqueness_of :child_id, scope: :parent_id
validates_uniqueness_of :child_id, scope: :parent_id, message: "^That relationship is already established."
scope :with_enterprises,
joins('LEFT JOIN enterprises AS parent_enterprises ON parent_enterprises.id = enterprise_relationships.parent_id').