[LRUG] Looping through classes

George Drummond georgedrummond at gmail.com
Thu Mar 14 03:30:34 PDT 2013


Since you are getting an error on line 1380 of lib/ohm.rb, why not inspect
what values are being iterated over


# Write the dictionary of key-value pairs to the model.
def update_attributes(atts)

  # Take a look at the value of atts
  puts atts.inspect

  atts.each do |att, val|
    send(:"#{att}=", val)
  end
end


Take a look on your local machine at what you get...



>  A better approach may be to fork the gem this is in and rewrite the
> methods that return a UTC date and have a conditional to return the unix
> timestamp?
>
> Now that is a really good idea! I'll see what I can do with that. I was
> thinking of running my conversion before upgrading Ohm and Ohm-contrib,
> because after upgrade, I can't even access any of the records:
> $ irb -r ./init.rb
> irb(main):001:0> Person[1]
> NoMethodError: undefined method `2011-02-25 21:52:26 UTC=' for :Person
>     from /home/user/app/current/vendor/ohm-1.2.0/lib/ohm.rb:1380:in `block
> in update_attributes'
>     from /home/user/app/current/vendor/ohm-1.2.0/lib/ohm.rb:1380:in `each'
>     from /home/user/app/current/vendor/ohm-1.2.0/lib/ohm.rb:1380:in
> `update_attributes'
>     from /home/user/app/current/vendor/ohm-1.2.0/lib/ohm.rb:1142:in `load!'
>     from /home/user/app/current/vendor/ohm-1.2.0/lib/ohm.rb:746:in `[]'
>     from
> /home/user/app/current/vendor/ohm-contrib-1.2/lib/ohm/slug.rb:9:in `[]'
>     from (irb):1
>     from /usr/bin/irb:12:in `<main>'
> irb(main):002:0>
> It would be a good idea to patch the new version to actually understand
> old data! Or in worst case, patch the old version to be able to write new
> data.
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20130314/d0027769/attachment-0003.html>


More information about the Chat mailing list