Displaying 20 results from an estimated 10000 matches similar to: "JSON PUT/POST/UPDATE"
2010 Dec 22
2
Rails - JSON object with an array?
Hello, I''m able to create and send a JSON object like so:
@mylist << {
:id => item.id,
:name => name.id
}
render :json => { :result => ''success'', :mylist => @mylist }
That works great. Problem I''m having now is that I need to include
users which can be 1 or users per item.
@mylist << {
2012 Sep 28
1
How to Include Associations in #as_json
Hi,
Does anyone know how to include nested associations when overriding a
model''s #as_json method?
Below is my attempt to include direct and nested associations.
NOTE: "office" is a direct association, "company" is nested association
via "office". I''d like both included in the generated json output.
def as_json(options={})
super(:include
2011 Oct 25
7
additional model attributes
Hi,
i have a "place" model with 2 columns (id, name).
I''m calling an external api which gives me data to create a new place
object.
I would like to add the address from the external place to the place
object and render it as a json result, without storing it in the
database.
i don''t get any errors, but the address never shows up within the json
output. i''ve
2012 Sep 18
4
"best practices" for Rails serving RESTful JSON services for use by AngularJS, Ember.js, etc.
I''ve been writing a gem to implement and extend common controller
functionality so that Rails can be used with Javascript frameworks like
AngularJS (which we are using), Ember.js, etc. in such a way that the user
doesn''t have to tweak a a bunch of rails g controller boilerplate code to
provide services for use in these frameworks that in turn would require
various changes to
2007 Mar 28
7
Rails, REST and JSON
Hi everyone,
I''m writing a lightweight AJAX application using Rails on the server side as
a RESTful web service provider.
I need the web service to support both JSON and XML I/O. Outputting data in
XML and JSON is easy (using to_xml and to_json),
and it''s also easy to do XML input as Rails does it for you automatically.
Is it possible to somehow have the same
automatic parsing
2007 Sep 01
2
Getting JSON from the body of a POST
I have a Flash application that is sending JSON data to a Rails app. I
want to be able to read the JSON from the controller. Does anyone know
where I can go to figure this out? I''ve Google''d around but can only
find instances of converting to JSON, not the other way.
Example:
Flash -> Sends JSON -> Rails Controller receives JSON and converts it to
a class
--
Posted
2018 Oct 04
3
CURL to post application/json
We tried to use the CURL fn to POST json, but it's sent as form data and
there seems no support for changing the Content-Type header. We switched to
invoking curl in the shell.
All the documentation I could find says there is just one parameter for the
url and an optional second for POST body. Is there an undocumented way to
set Content-Type?
-------------- next part --------------
An HTML
2012 Nov 30
1
q@ request.request_method=='OPTIONS', ajax, post json
hi
im reading through the topic above and trying to apply it to my app.
as reference i found:http://leopard.in.ua/2012/07/08/using-cors-with-rails/
my prob is that i dont see the ''preflight'', meaning the first request
prior the actual post, which should(?) deliver this:
request.request_method==''OPTIONS''
the js code look like this:
$.ajax
({
type:
2011 Feb 03
0
Correct way to exclude attributes from json serialization
Hi
I''m using Mongoid and Rails 3, and I want to serialize one of my
mongoid documents to json for publishing via a controller, e.g.
class ReportController < ApplicationController
respond_to :json
def show
report = Report.where(:report_id => params[:id]).first
respond_with report
end
end
This works ok, but pushes out every attribute on the document
2012 Jan 27
2
to_json performance
Originally posted on github, reported to the right place.
I would like to open a discussion about how `to_json` and `as_json`
operates in Rails from a performance standpoint.
I''m using Rails 3.2 but this issue applies to almost all versions of
Rails.
Our use case presents the challenge in sending out potentially large
JSON (or XML, but we''ll focus on JSON rendering here)
2013 Apr 15
4
Rails' scaffold controller generator - should it test json format also?
(Forgive me if this is incorrect, because I recognized this initially as
something in Rails 4.0.0.beta1 and have just done a cursory look over the
latest generator code.)
Noticed in Rails 4 that the test generated for a scaffold controller only
tests the html format instead of both html and json:
2010 Jun 08
8
rails, ajax, json, and script
Could someone please demonstrate the code to send both json (or xml) AND
javascript (to be executed) in a single Ajax request?
Is this even possible?
--
Posted via http://www.ruby-forum.com/.
--
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
2009 Jul 05
2
JSON data not decoded in Rails
Hello all,
I''m trying to send some json data from the browser to the server using
prototype without success. On the server side ActiveSupport::JSON.decode
isn''t decoding the data.
Here is the code:
Javacript:
<a href="#" onclick=''send();return false;''>click</a>
<script>
function send() {
var send_data_url =
2008 Dec 02
2
ActiveResource - xml and json format return different results
Hi,
I''m using Rails 2.1.2. and I wanted to switch ActiveResource format to
JSON and thought that it will work smoothly, but unfortunately it
wasn''t the case.
XML and JSON formats generate different objects:
XML version
#<User:0xb7658440 @prefix_options={}, @attributes={"created_at"=>Mon
Nov 28 11...}>
JSON version
#<User:0xb746af5c @prefix_options={},
2007 Dec 07
2
[ActiveSupport] Patches needing review: re-organization of #to_query methods, preservation of XML/JSON content-type
Just a quick pointer to some ActiveSupport patches hoping for reviews:
Puts Array#to_query and Object#to_query in the right places in
ActiveSupport - http://dev.rubyonrails.org/ticket/10395
Preserve user-specified content type for XML and JSON rendering
(currently it''s overridden and set to Mime::XML/Mimi::JSON -
http://dev.rubyonrails.org/ticket/10388
Oh and a tiny patch for
2009 Dec 08
0
ActiveSupport 2.3.5 and json 1.2.0 gem
Hey,
I''ve tried every trick I can find, yet I''m still unable to get the
json gem and ActiveSupport to play nice.
No matter in which order I load json and active support, I still end
up with: NoMethodError: undefined method `[]'' for
#<JSON::Ext::Generator::State:0x104b7fac0>
I''m trying to use the JSON object directly, *not* as a ActiveSupport backend:
2020 Jan 31
3
Does Libvirt's json parser support single quoted string in qmp json string?
Hi All,
I’m using qmp command via “virsh qemu-monitor-command” to perform block related jobs.
And in my case, I execute block-commit to commit the changes in the top image to the base image which is encrypted.
So in the base parameter, I need a json string which is single quoted to support the encryption parameters.
However, the virsh is failed to parse the whole json qmp command.
2009 May 07
2
Outputting strict JSON
Does any body know how I can output JSON so that instead of getting:
{booking: {id: 1, name: "foo"}
You get this instead:
{id: 1, name: "foo"}
Can''t find a solution for this at all
Thank you for any help.
2018 Aug 22
3
[PATCH v2 0/2] mltools: JSON: unify JSON & JSON parser.
v2:
- Added back the null value.
- Reran the tests.
Rich.
2020 Feb 03
2
Re: Does Libvirt's json parser support single quoted string in qmp json string?
On Fri, Jan 31, 2020 at 06:44:42AM -0600, Eric Blake wrote:
> On 1/31/20 4:38 AM, Peter Luo wrote:
>
> > error: internal error: cannot parse json {"execute": "block-commit", "arguments": { "device": "drive-virtio-disk2", "job-id": "job100",