search for: serializable_hash

Displaying 5 results from an estimated 5 matches for "serializable_hash".

2012 Jan 25
4
serializable_hash and serializable_add_includes
...tributes. I''m facing a problem when nested models are ''included'' using the :include option. The :only options for the parent model are also getting sent to the nested model(s). Here''s an example: model1.to_json(:include => model2, :only => [:id]) First serializable_hash gets called for model1 and is passed an options hash with :only set to an array including :id. This makes sense to me since the :only option was specified as a top level options. Next serializable_hash gets called for model2 and it is also passed an options hash that include :id in the :only opti...
2013 May 22
2
Creating nested hash from nested active record results
Hello, I''m trying to find a very abstract and "one size fits all" for converting nested active record results to nested hashes. It''s easy, to do one level deep as such: [code] results_to_hash = Hash[ found_categories.map{ |c| [c.id, c.title]}] [/code] But, when I try to add another collection to the mix, it completely borks and the results_to_hash only returns an
2011 Feb 03
0
Correct way to exclude attributes from json serialization
...would also like any embedded documents to have their _id properties excluded too. I have searched for info on as_json, to_json etc but I''m not sure which is the best practice approach. The closest I can get is: class Report include Mongoid::Document ... def as_json(options = {}) serializable_hash({ :except => :_id }.merge(options)) end end ...and then I need to copy that same as_json definition onto embedded document definitions too. Is this the rails 3 way of doing serialization customization? I tried defining as_json as: def as_json(options = {}) super({ :except => :_id...
2013 Feb 01
0
Add a customer renderer but I get missing template
...nd And my serializer: require ''msgpack'' module ActiveModel module Serializers module MPAC extend ActiveSupport::Concern include ActiveModel::Serialization included do extend ActiveModel::Naming end def to_mpac(options = nil) serializable_hash(options).to_msgpack end alias_method :to_msgpack, :to_mpac def from_mpac(msg) MessagePack.unpack(msg) end end end end Anyone has an idea ? Thanks. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk"...
2011 Jul 14
1
rails 3.0.9 ArgumentError (redundant UTF-8 sequence):
Hi guys, I have a simple controller def gmap @intentsearches = Intentsearch.all logger.info @intentsearches respond_to do |format| format.html {render :gmap} format.xml {render :xml => @intentsearches } format.json { render :json => @intentsearches } end end and want a json response, but i do get the following error Completed 500 Internal