Created
October 4, 2014 17:55
-
-
Save stevedomin/1444240501ee4ca30b30 to your computer and use it in GitHub Desktop.
Avoid encoding/decoding in controller create
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
def create(conn, %{"user" => u}) do | |
user = struct(User, u) | |
IO.inspect user | |
# %App.User{created_at: nil, email: nil} | |
end |
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
def create(conn, %{"user" => user}) do | |
user = struct(User, JSON.encode!(u) |> JSON.decode!(keys: :atoms!)) | |
IO.inspect user | |
# %App.User{created_at: nil, email: "[email protected]"} | |
end |
chrismccord
commented
Oct 4, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment