I have a User model with an id, name and url attribute and an associated Preferences model with an id and show_my_url fields.
I want to render my user as json but only include the url attribute if user.preferences.show_my_url is ‘true’.
How can i remove the users url attribute based on the preferences so that it´s not included in the to_json rendering.
1 Answer