Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't run in umbrella app #39

Closed
mbenatti opened this issue Apr 10, 2017 · 1 comment
Closed

Don't run in umbrella app #39

mbenatti opened this issue Apr 10, 2017 · 1 comment

Comments

@mbenatti
Copy link

mbenatti commented Apr 10, 2017

I have separated model and web in differents apps.

My model:

defmodule Tools.Model.Schemas.Vendor do
  use Ecto.Schema
  use Rummage.Ecto

  import Ecto.Changeset

  defmodule Type do
    use Exnumerator, values: [
      :constructor, :person, :corporation, :company, :real_state, :other
    ]
  end

  defmodule Size do
    use Exnumerator, values: [
      :small, :medium, :large, :unknown, :na
    ]
  end

  schema "vendors" do
    field :vendor_id, :string
    field :name, :string
    field :city, :string
    field :state, Tools.Model.Type.State
    field :description, :string
    field :notes, :string
    field :logo, :string
    field :size, Size
    field :type, Type

    timestamps()
  end

  @allowed [:name, :description, :notes, :logo, :size, :city, :type]
  @allowed_new [:vendor_id]
  @required [:vendor_id, :name, :type]

  def changeset_new(vendor, params \\ %{}) do
    vendor
    |> cast(params, (@allowed ++ @allowed_new))
    |> validate_required(@required)
    |> unique_constraint(:vendor_id)
  end

  def changeset_edit(vendor, params \\ %{}) do
    vendor
    |> cast(params, @allowed)
    |> validate_required(@required)
    |> unique_constraint(:vendor_id)
  end
end

The config and deps is ok

#IN config.exs
config :rummage_ecto, Rummage.Ecto,
  default_repo: Tools.Model.Repo,
  default_per_page: 10

#in mix.exs

defp deps do
   [{:ecto, "~> 2.1"},
    {:postgrex, "~> 0.13.2"},
    {:poison, "~> 3.1"},
    {:timex, "~> 3.1"},
    {:exnumerator, "~> 1.2"},
    {:rummage_ecto, "~> 1.1"}]
end

When I exec mix compile I got this:

== Compilation error on file lib/tools_model/feed_web/schemas/vendor.ex ==
** (UndefinedFunctionError) function Rummage.Ecto.__using__/1 is undefined or private
    Rummage.Ecto.__using__([])
    lib/tools_model/feed_web/schemas/vendor.ex:3: (module)
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6

May I need to add something like use Tools.Feed.Web, :model in the model?
If yes, I need to make Model app dependent of the Web, to see this module, this is not right...

@thebugcatcher
Copy link
Contributor

@mbenatti Rummage 1.1 doesn't have a __using__ macro defined. If you want to go this route, maybe change the version to 1.0 and it should work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants