ruby on rails - "Attribute was supposed to be a Hash, but was a String" -
i'm having problems saving hash in rails 3 application. can save ok when using console - doesn't work when submit hash through form.
this question addresses solution's not working me. moreover, if use:
serialize :bulk_action, hash i error:
attribute supposed hash, string the hash, when saved through form looks this:
"{\"location\"=>{\"commands\"=>{\"custom_command_one\"=>\"true\", \"custom_command_two\"=>\"true\"}}}" whereas, through console:
{"location"=>{"commands"=>{"custom_command_one"=>"true", "custom_command_two"=>"true"}}} my database field text field. what's best way go saving hash through form?
-- edit --
i've found can sort of around problem if use symbols not strings names still outputs 1 long string, not hash.
can switch json within textarea parsing isn't dangerous. because have eval respective params entry in controller or model enables users whatever want user under app running. json, use json.parse before setting model attribute.
Comments
Post a Comment