validatious-on-rails 0.3.8 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,12 +39,16 @@ module ValidatiousOnRails
|
|
39
39
|
module ClassMethods
|
40
40
|
|
41
41
|
def define_with_validatious_support(field_type)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
begin
|
43
|
+
define_method :"#{field_type}_with_validation" do |*args|
|
44
|
+
args, tail = ::ValidatiousOnRails::Helpers.extract_args!(*args)
|
45
|
+
options = self.attach_validator_for(args.first, args.second, args.extract_options!)
|
46
|
+
self.send :"#{field_type}_without_validation", *((args << options) + tail)
|
47
|
+
end
|
48
|
+
alias_method_chain field_type, :validation
|
49
|
+
rescue
|
50
|
+
# Rails version compability. Note: :respond_to? don't seems to work...
|
46
51
|
end
|
47
|
-
alias_method_chain field_type, :validation
|
48
52
|
end
|
49
53
|
|
50
54
|
end
|
@@ -52,4 +56,4 @@ module ValidatiousOnRails
|
|
52
56
|
end
|
53
57
|
end
|
54
58
|
|
55
|
-
::ActionController::Base.helper ::ValidatiousOnRails::Helpers
|
59
|
+
::ActionController::Base.helper ::ValidatiousOnRails::Helpers
|
@@ -2,7 +2,8 @@
|
|
2
2
|
require File.join(File.dirname(__FILE__), *%w[.. helpers])
|
3
3
|
#
|
4
4
|
# Tap into the built-in form/input helpers to add validatious class names from
|
5
|
-
# model validations.
|
5
|
+
# model validations. Only altering the options hash is interesting - we want to set a validator class for fields,
|
6
|
+
# so the hooking of these helpers don't have to be very explicit.
|
6
7
|
#
|
7
8
|
module ActionView # :nodoc:
|
8
9
|
module Helpers # :nodoc:
|
@@ -11,10 +12,6 @@ module ActionView # :nodoc:
|
|
11
12
|
include ::ValidatiousOnRails::Helpers
|
12
13
|
|
13
14
|
FIELD_TYPES = [:text_field, :password_field, :text_area, :file_field, :radio_button, :check_box].freeze
|
14
|
-
|
15
|
-
# Only altering the options hash is interesting - we want to set a validator class for fields,
|
16
|
-
# so the hooking of these helpers don't have to be very explicit.
|
17
|
-
#
|
18
15
|
FIELD_TYPES.each do |field_type|
|
19
16
|
define_with_validatious_support(field_type)
|
20
17
|
end
|
@@ -39,7 +36,6 @@ module ActionView # :nodoc:
|
|
39
36
|
include ::ValidatiousOnRails::Helpers
|
40
37
|
|
41
38
|
FIELD_TYPES = [:time_zone_select, :select, :collection_select, :grouped_collection_select].freeze
|
42
|
-
|
43
39
|
FIELD_TYPES.each do |field_type|
|
44
40
|
define_with_validatious_support(field_type)
|
45
41
|
end
|
@@ -51,7 +47,6 @@ module ActionView # :nodoc:
|
|
51
47
|
include ::ValidatiousOnRails::Helpers
|
52
48
|
|
53
49
|
FIELD_TYPES = [:date_select, :datetime_select, :time_select].freeze
|
54
|
-
|
55
50
|
FIELD_TYPES.each do |field_type|
|
56
51
|
define_with_validatious_support(field_type)
|
57
52
|
end
|