similar to: Correct way to exclude attributes from json serialization

Displaying 20 results from an estimated 900 matches similar to: "Correct way to exclude attributes from json serialization"

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
2008 Jan 21
1
help writing a usb hid driver for existing ups
I've got a Powercom Imperial UPS, with an internal USB<=>serial converter. It implements the same protocol as other powercom devices implements, but only when talking over serial port (there's no such port on the device). Someone wrote a draft version of usbserial driver for it, and the UPS works with this kernel-level driver and with powercom driver from nut (using /dev/ttyUSBx
2010 Feb 16
0
as_json and self-referential associations
Hi, I''m using the new(?) as_json methods within a rest api I am working on. However I am not sure how you are supposed to, or whether it is designed to handle multiple variations of association inclusion. For example I have a model using acts_as_tree, so that each instance has children and a parent: class CatalogueCategory < ActiveRecord::Base acts_as_tree JSON_ATTRS =
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:
2011 Jul 04
2
when use mongoid , Model.count can't work.
Hi, when i use mongoid to get the count of model named "User", I met a error : irb(main):001:0> User.count ArgumentError: wrong number of arguments (1 for 0) from /var/lib/gems/1.8/gems/mongoid-2.0.2/lib/mongoid/ cursor.rb:37:in `count'' from /var/lib/gems/1.8/gems/mongoid-2.0.2/lib/mongoid/ cursor.rb:37:in `send'' from
2013 Feb 01
0
Add a customer renderer but I get missing template
Hi, I''m trying to include the support of Msgpack<https://github.com/msgpack/msgpack-ruby> in Rails 3.2 but when I try to return a mpac response, I get an error concerning a missing template. My renderer: Mime::Type.register ''application/x-mpac'', :mpac ActionController::Renderers.add :mpac do |mpac, options| self.content_type ||= Mime::MPAC
2006 Oct 13
2
Splitting controller
I''m trying to split controller into several files. I tried extracting methods into separate files and then requiring them in main controller, but this doesn''t seem to work. controllers/reports/sales_reports.rb: class ReportController < ApplicationController def sales end end controllers/reports/purchases_reports.rb: class ReportController < ApplicationController def
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 Jul 12
1
Possible leaking records in dashboard db
I''m using puppet-dashboard 1.1.0-1 on Ubuntu. I remove old reports using this command: nice -n +1 rake RAILS_ENV=production reports:prune upto=1 unit=mon This seems to work fine, and the amount of reports returnd by this mysql query seems to drop by the proper amount: select count(*) from reports; Right now it returns a value of 12591. So far so good. The problem is the
2012 Jan 22
3
Using Mongoid with ActiveRecord
I''m trying to use mongodb and postgresql simultaneously with Rails 3.1. I believe I have everything set up correctly. What I''m interested in knowing is how to get rails to flip-flop back- and-forth between mongoid and activerecord. For example, if I want to generate an ActiveRecord model after using mongoid, rails automatically defaults to the Mongoid gem. > rails g model
2013 Oct 23
2
how is mongoid syntax implemented ?
In mongoid, a ORM mapped database object is like below. The part "type: String" seems to me to not fit into any standard ruby syntax and I was curious how does mongoid implement that ? class Step include Mongoid::Document field :Label, type: String field :Descript, type: String field :ErrorText, type: String embedded_in :step_data end -- You received this message
2010 Feb 25
0
Bundle install error involving hash range errors
While running "bundle install" on a new Rails3.0.0.beta app on Ubuntu 9.10 / Ruby 1.8.7 with the following line in my Gemfile: gem "mongoid", :git => "git://github.com/durran/mongoid.git", :branch => "prerelease" I got the following error: Installing mongoid (2.0.0.pre) from git://github.com/durran/mongoid.git (at prerelease)
2014 Mar 12
0
Developing the UPS side of the UPS-NUT equation (via usbhid)
So, going with the proposed initial design, I created a report descriptor to describe the battery. I thought that I'd then see how NUT responded to it. The good news is that the descriptor showed up and all of the paths were correct. Unfortunately, after that, nothing happened...no reports were requested, and it just kept timing out. Is there some minimum amount of functionality I need to
2010 Sep 23
0
rspec problems mocking classes based on mongoid
I am getting errors when running my rspecs. My project uses rails 3, mongoid, factory_girl, rspec 2.0.0.beta.22, rspec-mocs, etc http://pastebin.com/raw.php?i=WkaGiFag Getting: Failure/Error: @product = assign(:product, stub_model(Product, undefined method `to_sym'' for nil:NilClass I''m pretty sure stub_model has no clue on how to handle objects based on mongoid. Any ideas?
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''
2011 May 14
1
RSpec stub question
Hi I am using Mongoid. In Mongoid while saving a record we typically give like in the controller @post.safely.save For a model class Post I am writing rspecs for my controller and want to mock the model. So what I am doing is let(:post) { mock_model(Post).as_null_object } before(:each) do Post.stub(:new).and_return(post) end it "creates new post"
2014 Mar 10
0
Mongoid : bson namespace error
Hello All, I had been trying to work on Rails 4 and Mongoid gem. The following are the versions I had installed: bson-2.2.1 mongoid-3.1.6 After installing and trying to run "rails generate" command. It is failing with NameSpace error for BSON::ByteBuffer. It is trying to connect to mongodb server initially and getting successful. Post that it is failing with the following
2005 Nov 24
1
Log question
development.log contains quite a few SELECTS on system tables like COLUMNS. Wouldn''t it be more efficient to cache this info? I''m also wondering about strings like "[4;35;1m". What''s their purpose and is it possible to get rid of them? They look like screen coordinates and makes no sense in a text file. Christer Processing ReportController#create (for
2011 May 08
0
Mongoid rails 3
Hi, I am using mongoid, rails, mongohq. I have to tables Category and SubCategory Category references_many :subcategories SubCategory referenced_in :category Now I have a form in view. In view, when user chooses a category, an ajax request is made to get dependent subcategories. But problem is, it is returning empty array in response(this is using mongohq). It is working normally as expected
2011 Nov 09
0
beginner question: how do I figure out why an app won't start? (RubyMine)
I''m building a new Ruby app with RubyMine. I built a basic app (just a homepage) and it is running fine. Next step is to get the app talking to MongoDb. I''m using this tutorial: http://www.mongodb.org/display/DOCS/Rails+3+-+Getting+Started also tried this one: https://github.com/RailsApps/rails3-mongoid-devise The problem is, after running through the tutorial and starting my