Skip to content

Instantly share code, notes, and snippets.

@orbanbotond
Created September 20, 2013 08:53
Show Gist options
  • Select an option

  • Save orbanbotond/6634913 to your computer and use it in GitHub Desktop.

Select an option

Save orbanbotond/6634913 to your computer and use it in GitHub Desktop.
Serializer Usage
u = User.find '5209df7c2e21a971fd000027'
params = u.active_model_serializer.new(u, {}).as_json
roles = params[:roles]
roles.push( {"organization_id" => "5209df7c523f8fd8816767b3", "role" => :manager})
u.update_attributes params
class UserSerializer < ActiveModel::Serializer
attributes :_id, :name, :email, :timezone, :mobile, :password, :password_confirmation, :country_calling_prefix
has_one :address
has_many :roles
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment