Created
September 20, 2013 08:53
-
-
Save orbanbotond/6634913 to your computer and use it in GitHub Desktop.
Serializer Usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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