cannot encode association :taggables from VampDev.User to JSON because the association was not loaded. Please make sure you have preloaded the association or remove it from the data to be encoded
I am getting above error. I am trying to associate two table and could not able to connect (using MySQL). Please help to solve this issue Where to load the association ?
example code
# web/models.user.ex
defmodule VampDev.User do
use VampDev.Web, :model
@primary_key {:id, :string, []}
schema "users" do
field :name, :string
field :country, :string
many_to_many :tags, VampDev.Tags, join_through: "taggables"
end
end
# web/models.user_controller.ex
defmodule VampDev.UserController do
use VampDev.Web, :controller
def index(conn, _params) do
user = Repo.all(VampDev.User)
json conn, user
end
end
Thanks