problem about active-model-serializers-Collection of common programming errors


  • timpone
    ruby-on-rails ruby-on-rails-3.2 paperclip active-model-serializers
    I have an asset model class and it has different sizes using paperclip 3.5.2:class AssetSerializer < ActiveModel::Serializerattributes :id, :asset # works fine# would like to output small but don’t seem to be able to#attributes :id, :asset, :asset(:small) endIt’s a bit confusing because Paperclip uses the name class and the model is called class (ok really confusing). I get the following error:/Users/jt/repos/rails/app/serializers/asset_serializer.rb:2: syntax error, unexpected ‘(‘, expectin

  • shicholas
    ruby-on-rails-4 active-model-serializers
    I have a serializerclass FundingSerializer < ActiveModel::Serializerattributes :id, has_one :userhas_one :tournamentembed :ids, include: true endThat initializes with the proper associationsFundingSerializer.new(Funding.first).to_jsonyields”{\”users\”:[{\”id\”:2,\”first_name\”:\”Nick\”}],\”tournaments\”:[{\”id\”:1,\”end_date\”:\”2013-07-21T23:18:54.981Z\”,\”start_date\”:\”2013-07-14T23:18:54.980Z\”}],\”funding\”:{\”id\”:1}}”but, FundingSerializer.new(Funding.all).to_jsongets this error.undefi

  • Jesper
    ruby-on-rails active-model-serializers
    I’ve got two models:class Subject < ActiveRecord::Basehas_many :user_combinationshas_ancestry endclass UserCombination < ActiveRecord::Basebelongs_to :stagebelongs_to :subjectbelongs_to :user endAnd two serializers:class UserCombinationSerializer < ActiveModel::Serializerattributes :idbelongs_to :stagebelongs_to :subject endclass SubjectSerializer < ActiveModel::Serializerattributes :id, :name, :description, :subjectsdef include_subjects?object.is_root?enddef subjectsobject.subtreeen

  • Gawyn
    active-model-serializers
    When rendering the json of a model with nested associations I get the following error:undefined method `serializable_hash’ for #<ActiveModel::ArraySerializer:0x007fe761592d88>This is my code:class EventSerializer < ActiveModel::Serializerattributes :id, :name, :datehas_many :markets endclass MarketSerializer < ActiveModel::Serializerattributes :id, :bet_limit_timehas_many :options endclass OptionSerializer < ActiveModel::Serializerattributes :id, :name, :odds endThe error appears

  • user1938736
    ruby-on-rails ember.js active-model-serializers
    I’m trying to sideload data in active_model_serializer for an Ember application and get a NoMethodError when I attempt to include the objects:undefined method `object’ for #Email:0x00000100d33d20It only happens when :include => true is set, like this:class ContactSerializer < ActiveModel::Serializerembed :ids, :include => trueattributes :first_name, :last_namehas_many :emails endMy models look like this:class Contact < ActiveRecord::Baseattr_accessible :first_name, :last_name, :company,

  • benburton
    ember.js ember-data active-model-serializers
    I have a few models in Rails that look something like this:class Issue < ActiveRecord::Basebelongs_to :reporter, class_name: ‘User’belongs_to :assignee, class_name: ‘User’has_many :comments endclass User < ActiveRecord::Base endclass Comment < ActiveRecord::Base endwith serializers like so:class IssueSerializer < ActiveModel::Serializerattributes :idembed :ids, include: truehas_one :reporter, :embed => :idshas_one :assignee, :embed => :ids endclass UserSerializer < ActiveMod

Web site is in building