Created
March 10, 2011 08:47
-
-
Save hidenba/863778 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# changedの振る舞い | |
t = Event.new | |
param = {:year=>2000, :month=>'', :day=>nil} | |
t.attributes = param | |
t.changed? #=> true | |
t.year_changed? #=> true | |
t.month_changed? #=> false | |
t.day_changed? #=> false | |
t.changes #=> {"year"=>[nil, 2000]} | |
#============================================ | |
Event.all.each do |event| | |
param = params.detect {|id,val| id == event.id}.last | |
event.attributes = param | |
event.save! if event.changed? | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment