I'm using the framework Phoenix with Ecto Mongo and I'm trying to get all Groups(My model) and loop this in view.
@groups = Group |> GlobalDocs.Repo.all
And I'm getting this message error:
no match of right hand side value: [%Group{__meta__: #Ecto.Schema.Metadata<:loaded>, avatar_url: nil, description: "", group_id: 123, id: "585ea2ce6e8dee0a6c04ecf6", name: "TryGroup", slug: "try_group"}]
Why this? If I run this in IEx, this code works.
Thanks for this.
Elixir and Phoenix do not work the same way as Ruby and Rails does.
When you use an
@
variable. They are called module attributes. In Phoenix, you do not use module attributes in order to have a variable accessible in a view like you would with rails.In Phoenix, you would use something like the following.
Now, in your view, you will have access to a
@groups
variable.