I’m trying to use Hash object like as ActiveRecord Model within FormHelper:
<% hash = { :some_key => 'some_value' } %>
<% fields_for "hash", hash do |f| %>
<%= f.text_field :some_key %>
<% end %>
As far as I know, its trying to call :some_key method for hash object. I was trying to override ‘send’ method for Hash class but have no luck:
def send( symbol, args = [] )
if self.has_key?( symbol )
self[ symbol ]
elsif self.has_key?( symbol.to_s )
self[ symbol.to_s ]
else
super
end
end
Have you any ideas how could I play with this?
Thanks for your help.
Many thanks to KL-7 for his proposition of OpenStruct. So, if someone need this, I’m adding here full working example.
And now it’s time for OpenStruct: