similar to: ActiveSupport JSON working?

Displaying 20 results from an estimated 3000 matches similar to: "ActiveSupport JSON working?"

2007 Aug 07
2
"badly formed JSON" exception
I tried to implement the "Rendering JSON in actions" example from http://wiki.rubyonrails.com/rails/pages/HowtoGenerateJSON : @headers["Content-Type"] = "text/plain; charset=utf-8" data = { :foo => ''bar'', :etc => ''rez'' } render :text => data.to_json When I try to decode this in javascript with
2007 Dec 27
5
Rails 2.02 dropped JSON attribute tag ?
Hey there I was scratching my head over why my application breaks when I run on a local server but works on my remote server. It turns out that my local server is Rails 2.0.2 and my remote server is 1.2.3 and I expect the tag "attributes" to be passed with a json stream, before parsing. Unfortunately, this was dropped in 2.0.2. Is there any documentation on this? Any way to get it back?
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
2007 Oct 04
4
2 more JSON / XML feature parity patches before Rails 2.0
I''d really like to see just 2 more functional changes to the JSON serialization/encoding before we get to Rails 2.0. First, and I think this is really crucial because without it all the efforts to output JSON from ActiveRecord objects would have been half in vain, is to allow us to do this in controllers: @authors = Author.find(:all) render :json => @authors.to_json(:only =>
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:
2006 Jan 23
4
an image that is a clickable link?
Hi, How do I make an image that is a clickable link the rails way? Is there a view helper for this? Thanks, Peter
2011 Aug 25
7
How to safely embed JSON object in HTML document
Hi all, I''m working on a Backbone.js single page app with Rails 3.1, and in an attempt to save on HTTP requests, I want to embed initial data set in a HTML document that is sent back to the browser after successful login. I was thinking I can simply convert my ruby object to JSON, then HTML escape resulting string of JSON, and then use that as a value for JavaScript variable. Something
2007 Oct 02
0
More JSON and XML feature parity for AR and ActiveSupport (patch review)
I''m really glad the JSON changes got in, many thanks to all involved, committers and contributors alike :). But there''s still one feature that''s missing to achieve feature parity between the JSON and XML encoding/conversion. And that is the abililty to say in your controller: @authors = Author.find(:all) render :json => @authors.to_json(:only => :name)
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
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
2007 Sep 28
2
Rails shouldn't output invalid JSON by default
Please check out this ticket (which would explain almost everything): http://dev.rubyonrails.org/ticket/8762 So basically, Rails to_json methods produces invalid JSON out of the box as it doesn''t quote all hash keys. This is valid JSON: { "id": 6589, "code": "SIN", "name": "Singapore" } This is not (Rails'' JSON encoders
2006 Jan 19
7
validates_numericality_of positive integer
Hi, What is the simplest way to validate a positive integer? validates_numericality_of :foo, :integer_only => true how do I add the positive part? Do I need another validation statement for pattern matching or do I have to write a validate() funciton for my model? Thanks, Peter
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
2006 Apr 26
10
save new model with child model
Hi, I am having a problem saving a new model that has an associated child model. If a new ticket is being created and will have one comment to go with it then I tried this in my action @ticket = Ticket.new(params[:ticket]) @comment = Comment.new(params[:comment]) @ticket.comments << @comment if @ticket.save @notice = "Ticket added. Thanks for
2007 Mar 24
0
overloading to_json with JSON gem installed causing error
I installed the JSON gem because I wanted the JSON parser. Before installing the JSON gem, overloading worked fine. Before I remove it, I''d like to see if anyone has an idea of what is going on. It''s the only JSON parser I''m aware of, so it would be a bummer if it didn''t work. After installing, if I overload the to_json method in the class, it gives me the
2006 Jul 07
5
Can a route require POST or GET? / REST problem with routing
Hi, A store front a customer wants to GET /product/5/show. But for the application this is really GET /cart_item/new/5 or even better /cart_item/new?cart_item[product_id]=5 When the customer clicks add_to_cart they POST /product/5/show so that the url doesn''t confuse the user when any validation errors occur. But for the applicaiton this should be POST
2006 Mar 22
14
currency conversion webservice in a rails app?
Hi, I''m interested in using a currency conversion web service in my rails app. Does anyone have a free service that they use and like? I found this one http://www.webservicex.net/WS/WSDetails.aspx?CATID=2&WSID=10 I''ve tried to make a simple, plain Ruby script to connect to this and get a conversion rate without success. How do I integrate a webservice into my rails app? I
2006 Apr 01
4
problems getting ActionMailer working (on server)
Hi, I''ve read the Agile Rails book''s chapter on ActionMailer a few times. Seems pretty straight forward. Unfortunately I can''t get my application to actually send mail. I uploaded my application to the web server and tried to get a mail message sent. Nothing happened. I looked in the log file and it says Sent mail: From: service@freedomkilts.com To:
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
2008 Jul 12
0
to_json in Rails 2.0.2 not generating proper json?
I am using Rails 2.0.2 and trying to use to_json to generate json. I notice several problems. 1) datetime field such as created_at mapped to "created_at": {} 2) :except does not work, @post.to_json(:except => [:created_at, :updated_at] still gives me "created_at": {}, "update_at": {} 3) problem with escaped char mapping: ''<'' mapped to