My question is the next:
When i try parse a json params with 'json' gem on RUBY ON RAILS 3 throw this error:
Unexpected token at
Example
I have this object in ruby:
Then I have this html code:
<script>
$("#selected").live('click', function(){
jQuery.ajax({url: '<%= deselect_all_checkboxes_path %>', data: {contacts: '<%= contacts.to_json %>'}});
});
</script>
<input type="checkbox" id="selected" value="1" >
I try this code in Rails Console
JSON.parse(json_string.gsub(/"/, "\""))
Works ok. However when i try this code:
JSON.parse(params[:contacts].gsub(/"/, "\""))
There is a problem in the gsub method. In Rails Console works ok but when i am debugging throw the error message. The problem is with ";" character.
Which could be the error?