Hello,
I am using the to_json method to encode models to json. Standard
stuff. I am using the :include option so that a relation model gets
added to the encoded json. Again this is fine however the related
model is a user model that has things like md5 password strings. Whats
the best way of excluding these fields form the encoding. Here is the
current line of code that calls the to_json method
format.js { render :json => @shifts.to_json(:include => [ :users ]) }
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Stewart wrote in post #989366:> Hello, > > I am using the to_json method to encode models to json. Standard > stuff. I am using the :include option so that a relation model gets > added to the encoded json. Again this is fine however the related > model is a user model that has things like md5 password strings. Whats > the best way of excluding these fields form the encoding. Here is the > current line of code that calls the to_json method > > format.js { render :json => @shifts.to_json(:include => [ :users ]) }I believe you want: @shifts.to_json(:include => { :users => { :except =>[ ''password''] }}) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.