[Rails] Re: Rails 3 and application/json
I replied to this earlier but I think I may have accidentally clicked
discard instead of send. Sorry if this is a duplicate:
I tried that method (using respond_with). Even then the requests gets
processed as HTML.
So on my Rails 2 setup just setting CONTENT_TYPE = 'application/json'
causes the request to be processed as a json format.
On Rails 3 that isn't working so everything gets set as HTML. Do I
need to set HTTP_ACCEPT instead of CONTENT_TYPE? I get the feeling
Rails 3 uses CONTENT_TYPE for the incoming parsing (since the incoming
json is parsed correctly) and I need to set some other type to force a
JSON *response*. It isn't clear where that should be set though.
Thanks
Joe
On Jun 8, 1:18 am, Peter De Berdt <peter.de.be...@pandora.be> wrote:
> On 08 Jun 2011, at 09:17, pipplo wrote:
>
> > I have a rails 2 app that I am upgrading to rails 3.
>
> > I am exposing a web service to a phone app. When I make a request
> > from the phone application the CONTENT_TYPE is application/json
>
> > In rails 2 my controller recognizes this as json, but in rails 3 my
> > controller recognizes it as html.
>
> > respond_to do |format|
> > format.html { }
> > format.json { }
> > end
>
> > Any ideas why the format isn't being set to json in rails 3? Do i
> > have to do something to enable json routing?
>
> This might be useful:http://ryandaigle.com/articles/2009/8/10/what-s-new-in-edge-rails-def...
>
> Best regards
>
> Peter De Berdt
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home