So I am trying to implement nice meta-data concept in my application. Basically, I store some details in XML format in a single column in the database but in my application I can access them through a Hash.
def extra_info=(data)
data = {} unless data.is_a?(Hash)
self[:extra_info] = data.to_xml(:dasherize => false)
end
def extra_info
Hash.from_xml(self[:extra_info])['hash']
end
Rather simple, following what I read on a blog post on the subject.
However, now my application throws an error:
ERROR ArgumentError: wrong number of arguments (1 for 0)
.../app/models/users/usage.rb:35:in to_xml
So I tried this
def extra_info=(data)
data = {} unless data.is_a?(Hash)
self[:extra_info] = data.to_xml
end
And still I get the same error! Anyone faced this issue? What’s wrong?
Turns out this was a backward compatibility issue with the version of builder included in Rails. Problem with REE only.
From elisehuard on github:
Criminal. Anyway, much thanks to her for the fix, which can be found here.