diff --git a/lib/gql_preferences/preference.ex b/lib/gql_preferences/preferences.ex similarity index 51% rename from lib/gql_preferences/preference.ex rename to lib/gql_preferences/preferences.ex index 036eaa6..0a82405 100644 --- a/lib/gql_preferences/preference.ex +++ b/lib/gql_preferences/preferences.ex @@ -1,4 +1,4 @@ -defmodule UserPreferences.Preference do +defmodule UserPreferences.Preferences do use Ecto.Schema import Ecto.Changeset @@ -11,9 +11,9 @@ defmodule UserPreferences.Preference do end @doc false - def changeset(preference, attrs) do - preference - |> cast(attrs, [:likes_emails, :likes_phone_calls]) - |> validate_required([:likes_emails, :likes_phone_calls]) + def changeset(preferences, attrs) do + preferences + |> cast(attrs, [:likes_emails, :likes_phone_calls, :user_id]) + |> validate_required([:likes_emails, :likes_phone_calls, :user_id]) end end diff --git a/lib/gql_preferences/user.ex b/lib/gql_preferences/user.ex index 1709af1..fad7b18 100644 --- a/lib/gql_preferences/user.ex +++ b/lib/gql_preferences/user.ex @@ -5,7 +5,7 @@ defmodule UserPreferences.User do schema "users" do field :email, :string field :name, :string - has_one :preference, UserPreferences.Preference + has_one :preferences, UserPreferences.Preferences timestamps() end