Schema 'rememberable' uses wrong user association.
jung-hunsoo opened this issue · 3 comments
jung-hunsoo commented
My code shows warning in rememberable module like this;
warning: invalid association `user` in schema Myapp.Coherence.Rememberable: associated schema Myapp.Myapp.Coherence.User does not exist
lib/myapp/coherence/rememberable.ex:1: Myapp.Coherence.Rememberable (module)
It seems that the generated module schema has an error code of belongs_to :user, Module.concat(Config.module, Config.user_schema)
.
The right code would be belongs_to :user, Config.user_schema
since the auto-generated coherence config has user_schema: Myapp.Coherence.User
which means it has top module name Myapp
already.
smpallen99 commented
not sure what is going on in your setup. Perhaps you are using an old version of coherence?? Here is the code directly from the generator template:
defmodule <%= base %>.Coherence.Rememberable do
@moduledoc false
use Ecto.Schema
import Ecto.Changeset
import Ecto.Query
alias Coherence.Config
<%= if use_binary_id? do %>
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
<% end %>
schema "rememberables" do
field :series_hash, :string
field :token_hash, :string
field :token_created_at, :naive_datetime
belongs_to :user, Config.user_schema()<%= if use_binary_id?, do: ", type: :binary_id", else: "" %>
timestamps()
end
# ...
smpallen99 commented
Closing issue due to lack of response from OP.
jung-hunsoo commented
Sorry for late. You're right I'm in v0.5.0. Actually I configured then it works fine.