# JSON problems in update method (ExtJs, Ext)

**URL:** <https://www.ruby-forum.com/t/json-problems-in-update-method-extjs-ext/152514>\
**Category:** Rails\
**Created:** [November 4, 2008, 7:45pm UTC](https://www.ruby-forum.com/t/json-problems-in-update-method-extjs-ext/152514 "2008-11-04T19:45:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hirodusk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/6f9a4e/32.png) [@hirodusk](https://www.ruby-forum.com/u/hirodusk)\
**Post date:** [November 4, 2008, 7:45pm UTC](https://www.ruby-forum.com/t/json-problems-in-update-method-extjs-ext/152514/1 "2008-11-04T19:45:53Z")

</div>

Hello rubyonrails peeps, my first post here.

I’ve been having a lot of trouble today getting my controller to  
respond properly to an update request via json, coming from an  
EditorGridPanel in ExtJS. I started off by using the ExtScaffold  
plugin (which is great but limited in its examples), and hacked together  
a helper for Ext’s EditorGridPanel.

I’ve tried both the json\_request plugin and the built in rails 2.1  
json handling. Both end up with the same problem:

e.g.  
NoMethodError (undefined method `{“id”:6, … }=’ for  
#ModelName:0xb5957c74): etc…

So the JSON is not being parsed out as a nice neat params hash. I’m at  
the point where I’m about to write my own parser or call the  
json\_request method directly to try and get this working. I’ve been  
checking my json requests in Firebug and it seems to be ok, with the  
required ‘application/json’ content-type:

Accept: application/json  
Content-Type: application/json  
authenticity\_token: bcc54a2ffef408f8b0829cf310cabd411311fb92  
post:  
{“id”:4,“business\_requirement[project\_id]”:2,“business\_requirement[description]”:“…”,  
… }

The only difference my json seems to have from the examples given in  
both json\_request examples and Rails  
2.1 examples  
([http://www.digitalhobbit.com/archives/2008/05/25/rails-21-and-incoming-json-requests](http://www.digitalhobbit.com/archives/2008/05/25/rails-21-and-incoming-json-requests)  
) is that the format is  
post: {“id”:4,“model\_name[field\_name]”:2,“model\_name[field\_name]”:“text”  
…  
}  
rather than post: {“id”:4,field\_name:2,field\_name:“text” … }  
(with the Rails 2.1 version ‘post’ is replaced by the model name)

my controller looks like this:

def update  
respond\_to do |format|  
if  
find\_business\_requirement.update\_attributes(params[:post])  
format.ext\_json { render :json =\>  
this.to\_ext\_json(:success =\> true) }  
else  
logger.debug(“update failed!”)  
format.ext\_json { render :json =\>  
this.to\_ext\_json(:success =\> false) }  
end  
end  
end  
I’ve tried everything I can think of … it seems like I’m missing  
something to trigger the json parsing, but I just don’t know what at  
the moment.

Any help or ideas much appreciated!!

Thanks
