mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
Rails 2.2 compatibility fixes with more version check hackery (yuck, will fix later)
This commit is contained in:
parent
2f162ca500
commit
604a792e25
@ -1,5 +1,6 @@
|
|||||||
[2008-10-28]
|
[2008-10-28]
|
||||||
- fixed bug when dirty attributes not reflecting change when attribute changed from time value to nil [reported by Brad (pvjq)]
|
- fixed bug when dirty attributes not reflecting change when attribute changed from time value to nil [reported by Brad (pvjq)]
|
||||||
|
- fixes for Rails 2.2 compatibility. Will refactor in to Rails version specific branches in the future.
|
||||||
|
|
||||||
[2008-09-24]
|
[2008-09-24]
|
||||||
- refactored attribute write method definitions
|
- refactored attribute write method definitions
|
||||||
|
|||||||
@ -7,15 +7,25 @@ module ValidatesTimeliness
|
|||||||
module InstanceTag
|
module InstanceTag
|
||||||
|
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.alias_method_chain :date_or_time_select, :timeliness
|
if Rails::VERSION::STRING >= '2.2'
|
||||||
base.alias_method_chain :value, :timeliness
|
base.class_eval do
|
||||||
|
alias_method :datetime_selector_without_timeliness, :datetime_selector
|
||||||
|
alias_method :datetime_selector, :datetime_selector_with_timeliness
|
||||||
|
end
|
||||||
|
else
|
||||||
|
base.class_eval do
|
||||||
|
alias_method :datetime_selector_without_timeliness, :date_or_time_select
|
||||||
|
alias_method :date_or_time_select, :datetime_selector_with_timeliness
|
||||||
|
end
|
||||||
|
end
|
||||||
|
base.alias_method_chain :value, :timeliness
|
||||||
end
|
end
|
||||||
|
|
||||||
TimelinessDateTime = Struct.new(:year, :month, :day, :hour, :min, :sec)
|
TimelinessDateTime = Struct.new(:year, :month, :day, :hour, :min, :sec)
|
||||||
|
|
||||||
def date_or_time_select_with_timeliness(*args)
|
def datetime_selector_with_timeliness(*args)
|
||||||
@timeliness_date_or_time_tag = true
|
@timeliness_date_or_time_tag = true
|
||||||
date_or_time_select_without_timeliness(*args)
|
datetime_selector_without_timeliness(*args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def value_with_timeliness(object)
|
def value_with_timeliness(object)
|
||||||
|
|||||||
@ -32,7 +32,10 @@ puts "Using #{vendored ? 'vendored' : 'gem'} Rails version #{RAILS_VER} (ActiveR
|
|||||||
|
|
||||||
ActiveRecord::Base.default_timezone = :utc
|
ActiveRecord::Base.default_timezone = :utc
|
||||||
|
|
||||||
if RAILS_VER >= '2.1'
|
if RAILS_VER >= '2.2'
|
||||||
|
Time.zone_default = ActiveSupport::TimeZone['UTC']
|
||||||
|
ActiveRecord::Base.time_zone_aware_attributes = true
|
||||||
|
elsif RAILS_VER >= '2.1'
|
||||||
Time.zone_default = TimeZone['UTC']
|
Time.zone_default = TimeZone['UTC']
|
||||||
ActiveRecord::Base.time_zone_aware_attributes = true
|
ActiveRecord::Base.time_zone_aware_attributes = true
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user