similar to: Advanced use of to_xml and to_json

Displaying 20 results from an estimated 2000 matches similar to: "Advanced use of to_xml and to_json"

2009 Jan 21
3
Nested serialization with to_json and to_xml with array and hash element
Title: Nested serialization with to_json and to_xml with array and hash element class Person < ActiveRecord::Base has_one :address has_one :job def office() return "Executive_Suite" end end class Address < ActiveRecord::Base belongs_to :person end class Job < ActiveRecord::Base belongs_to :person has_one :paygrade def Title return "Engineer" end end
2006 Jul 31
2
is it possible to make to_xml use underscore instead of dash?
Hi all, I am getting ActiveRecord to produce XML with render :xml => @user.to_xml However, on the client end it is a bit annoying for me to deal with attributes like first-name. I would much rather have first_name. Is there any way for me to turn off the behavior of converting _ to -? This seems to be done by a call to dasherize inside the to_xml of
2009 Jan 09
2
Confused about to_xml() in ActiveRecord::Base subclass
Since all my efforts to control how to_xml() is formatting dates has failed, I''m now considering writing my own to_xml(). However, from the limited examples I''ve found, I just don''t understand how to actually reference the columns for the records in my record set. Here''s a simplified view of my ActiveRecord object: class Errors < ActiveRecord::Base
2009 Jan 21
1
AR to_xml problem with associations, Builder::XmlMarkup#to_a
When I do a to_xml(with a block) on an association of a model I got a Builder::XmlMarkup#to_ary should return Array Example that does not work. @intervenant = Intervenant.find(params[:id]) output = @intervenant.to_xml( :skip_types => false, :dasherize => false) do |xml| @intervenant.individu.to_xml( :builder => xml, :skip_instruct => true, :skip_types => false,
2010 Apr 05
2
Harmonizing JSON/XML serialization
The way Rails handles root nodes in JSON and XML serialization is inconsistent. This has been discussed before: https://rails.lighthouseapp.com/projects/8994/tickets/2584-232-activeresource-json-doesnt-send-parameters-with-root-node This seems mostly taken care of with ActiveModel::Base.include_root_in_json, especially if/when it ends up in ActiveResource. However, there is also the issue of how
2010 Jul 14
3
`stack level too deep` when overwriting `to_json`
I''m using [acts_as_commentable_with_threading](http://github.com/elight/acts_as_commentable_with_threading/), and it worked fine until I tried to overwrite the to_json function to include more details about the associated user. Here''s part of the comment class (which was originally defined in the plugin, but I moved it to the models folder, a move which seems not to affect the
2012 Jan 25
4
serializable_hash and serializable_add_includes
I''m trying to write a helper method similar to attr_accessible but instead it will be used to whitelist which attributes are available for serialization (attr_serializable). My first attempt at this was to override serialized_hash and modify the :only option to include nothing but serializable attributes. I''m facing a problem when nested models are ''included''
2007 Oct 23
2
to_json inconsistency?
Hello, ActiveSupport::JSON::Variable.to_json is the only to_json without an "options" parameter. Is this intended? For example, this code in a .rjs page[@user.dom_id].visual_effect :drop_out, :afterFinish => ActiveSupport::JSON::Variable.new("foo") fails with ActionView::TemplateError: wrong number of arguments (1 for 0) On line #7 of
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 May 17
4
Namespaced model valid #to_xml support in ActiveRecord, ActiveSupport and ActiveResource
Hi, Attached are links to two patches I submitted via the RoR Trac system a week or so ago: http://dev.rubyonrails.org/ticket/8305 http://dev.rubyonrails.org/ticket/8308 I refrained from creating a new Trac ticket for ARes, which will be affected if both of these patches are accepted by Core. There are a couple of workarounds for this issue, but it would be nice for AR, AS and ARes to output
2009 Aug 07
0
How to specify ActiveRecord's to_json encoding
Question: Hi, our company is using Ruby 1.8.6 with Rails 2.2.2. Does anyone know we can explicitly specify what encoding to use when calling to_json() or to_xml() methods? Problem: We have some multibyte characters in our database. For example we have a table with a name column that has this French accented e: Café Records. When we serialize this object using ActiveRecord''s to_xml()
2009 Jun 14
3
Basic AJAX Response (Mootools)
Hi, I''ve done AJAX calls to Rails'' Controllers before yet never required to generate a response back to the view. In this respect, I have tried to keep it moronically simple and just add a node to see that it works, yet the response doesn''t come through / isn''t interpreted as it should. Long story short, code : // Have to use Mootools to integrate a
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)
2009 Feb 23
2
to_json problem (Rails2.2.2)
Hi all, i got a record from my project server side database, like this : @user = User.find 1 then i cover @user to json format: @user.to_json the result : "created_at": "2009-01-28T12:29:32Z" what''s the T and Z of created_at field ? but i change Rails 2.2.2 to Rails1.1.6, I got : "created_at":
2010 Jul 17
1
not able to find to_yaml definition
I am looking at rails edge source code. I am able to do puts User.find.to_yaml However I am not able to find piece of code where ''def to_yaml'' is. How this to_yaml serialization is working? can fully understand how to_json and to_xml is working but to_yaml beats me. Thanks -- You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2007 Dec 11
0
help for hash.to_json
hi , all under rails 2.0 aotianlong@aotianlong:~/workspace/killer$ ruby script/console Loading development environment (Rails 2.0.1) >> {:user=>"aotianlong"}.to_json => "{\"user\": \"aotianlong\"}" >> user = User.find :first => #<User id: 1, uname: "aotianlong"> >> user.to_json =>
2011 Apr 17
0
newbie: to_json only/except + association confusion
hi, i want to return to_json with ''only'' and also filtered.so i tried various ways, but none of them are really good: A)#OK , but filter missing format.json { render :json => @project.to_json(:only => [:title ], :include=> { :tasks => {:only=>[:id,:title] } } ) } B)#Not OK > filter does not work, format.json { render :json => @project.to_json(:only
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
2013 Jan 07
0
Simplified to_json method API
Sometimes to_json options feels abusing to me: user.to_json(:only => [:id, :name], :methods => [:something]) I would prefer an API like this instead: user.to_json(:id, :name, :something) What do you think about adding a use case like this to to_json? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this
2012 Mar 13
7
ROC Analysis
Hi everybody, I have a data set with a value and a status (positive or negative case) and I want make a ROC Analysis. So, with ROCR Package, I have got the ROC curve (True Positive Fraction [tpf] according 1-True Negative Fraction [1-tnf]). http://r.789695.n4.nabble.com/file/n4469203/01.png But, now I want a new graphic which show the sum of true positive fraction and true negative fraction