hello list,
ive got a simple problem of copying a row to another table
the to tables have enough identical columns, so i used the attributes
hash of my object
to get less work with it
the my piece of code for that
def activate
@priv_property = PrivProperty.find(params[:id])
cols = {}
@priv_property.attributes.each do |k, v|
tmp = {k.intern => v}
cols.merge(tmp)
tmp.clear
end
cols[:adat] = Time.now
cols[:edat] = Time.now
cols[:sendetermin] = Time.now
cols[:mkunr] = cols[:maknr]
cols[:maknr] = 111
cols[:refnr] = cols[:reccou]
cols[:rc] = cols[:refnr]
cols.delete(:reccou)
cols[:reccou] = nil
[“objstatpriv”, “objreccou”, “objaktiv”, “objdeaktiv”, “objlztage”,
“vertrag”, “objretage”, “objbrutto”, “objmwst”, “zahlart”, “dtadat”,
“woher”, “refnr”].each do |c|
cols.delete©
end
property = Property.new
property.save!
ActiveRecord::Base.whiny_protected_attributes = false
property.update_attributes(cols)
ActiveRecord::Base.whiny_protected_attributes = true
render :nothing => true
end
fetching and so on is ok but the attributes hash has string indexes
and updates_attributes calls symbols
so i decided to solve this by convert the string index to symbol into
a new hash named cols
but that doesnt work
and my question is why it doesnt work?
have anybody a good solution or tipp for my problem?
thanks