Closed ChrisMacNaughton closed 8 years ago
While built-in support is not available, an alternative would be to override whatever modules are necessary to refactor. E.g., for the route /register
you'd do something like this:
# YourController.ex
(...)
def register(conn, user_params) do
{:ok, user} = Addict.ManagerInteractor.create(user_params)
{conn, %{user: user}} = Addict.SessionInteractor.register({:ok, user}, conn)
user = your_function_to_inject_associations(user)
json conn, your_function_to_jsonify(user)
end
(...)
#router.ex
(...)
addict :routes,
register: [controller: YourController, action: :register ]
(...)
Would something like this fix your issue?
Closing for now, please reopen if the issue still persists.
My user model has multiple associations on it and apparently breaks in the SessionInteractor when trying to render JSON because the associations are not loaded. I would like a way to configure the attributes to send with the user instead of just removing a few attributes in the sanitize_user method.