ecto Questions

2

Solved

I am writing a simple CRUD app in Phoenix, where admins, upon creating a new organisation are allowed to provision it with an initial staff member account. Effectively the relationship between Org...
Herv asked 23/12, 2015 at 20:50

1

Solved

I have query: PhoenixApp.one(from r in PhoenixApp.Reply, where: r.inserted_at > ^datatime, select: count(r.id)) This query fails with error: value '#Ecto.DateTime<2016-12-04 20:11:21&gt...
Varices asked 8/1, 2017 at 11:34

1

I'm really new to Phoenix/Elixir and I'm trying to wrap my head around changesets. I understands it holds a set of changes that is use to either create or update a model. What I would like to kn...
Grussing asked 10/6, 2016 at 19:14

2

I'm trying to test uniqueness in my database and I'm having a little trouble. I ran this migration: def change do create table(:signups) do add :name, :string add :email, :string timestamps()...
Sheppard asked 11/9, 2016 at 19:42

2

Solved

What is the way to handle associations and nested forms in Phoenix framework? How would one create a form with nested attributes? How would one handle it in the controller and model?
Bowens asked 17/8, 2015 at 15:47

1

Solved

Let's say I have a model with a field sizes that is an array (e.g. sizes: ['S', 'M', 'L']). What I want to accomplish, building an API, is for a user to be able to filter those models based on size...
Heterocyclic asked 21/12, 2016 at 0:54

2

Solved

I'm getting an error when trying to create a database. I have postgres installed and I've already made a few test projects successfully. And, I've not seen this error. Any help would be great: ERR...
Photoperiod asked 19/7, 2016 at 2:0

2

Solved

I am building an Ecto query like this: from item in query, where: like(item.description, ^"%#{text}%") I'm concerned that this allows SQL injection in text. Before trying to fix that, I want to ...
Hyperdulia asked 7/12, 2016 at 15:40

1

I was happily following this advice on how to run a pry debugger inside my Phoenix controller tests: require IEx in the target file add IEx.pry to the desired line run the tests inside IEx: iex -...
Strenuous asked 29/11, 2016 at 23:25

1

I have a model that I would like to partition across multiple database tables. All the data and functionality will be the same so I would like to use the same module/ecto.model but just have the ta...
Bandler asked 18/11, 2016 at 22:55

2

Solved

I am writing an Elixir project that connects to a Postgres database via Ecto. The database server is on a different server from the application itself, and is more subject to outages that would not...
Vauban asked 27/6, 2016 at 15:38

2

In Elixir, the pin operator is used to prevent variable rebinding. However, with regard to an Ecto query like from u in User, where: u.username == ^username the authors of Programming Phoenix st...
Dominga asked 8/11, 2016 at 10:39

1

Solved

It's not clear to me how to delete a many to many association in Ecto. I do not want to delete the associated structures, just the relationship. My first attempt was to find the association in joi...
Quar asked 7/11, 2016 at 1:52

1

I have an ecto model with many_to_many association. I put couple of associated models to the changeset via put_assoc and want to validate amount of associated models. How can I do that? Example mod...
Bagwig asked 5/11, 2016 at 9:31

1

Solved

I need to convert a string containing a valid UTC time to an Ecto.DateTime one, which I will insert it into my database with the correct format later. I have tried using the Ecto.DateTime.cast(date...
Promotion asked 6/11, 2016 at 1:0

2

Solved

It looks like a simple feature is coming for this issue, but Phoenix Ecto doesn't have it yet. What is a workaround in the meantime for a where-or query in Ecto? For example: from(u in User, lef...
Gob asked 1/11, 2016 at 17:33

1

Solved

I can't update nested settings with ecto, I either get "no changes" changeset or errors. Migration: def change do create table(:trees) do ... add :settings, :map Settings looks like: defmodu...
Conviction asked 28/10, 2016 at 16:24

1

I'm new to Elixir and Ecto and I would need some help with Ecto's has_many and cast_assoc. Can't understand the basics, like how am I to create a new model with assoc one. Here's my Has_Model: de...
Unfix asked 4/10, 2016 at 20:40

2

What function can I use to check if a association is already loaded? It would be nice to check if a association is loaded instead of trying to use it and getting Ecto.Association.NotLoaded error.
Hart asked 27/6, 2016 at 6:47

2

Solved

I'm trying to insert an invoice struct along with its associated invoice items. I'm able to insert the invoice data, and call an anonymous function to validate, cast, and insert each item. Since in...
Gladiate asked 28/3, 2015 at 4:32

1

Let say I have a model, like that: defmodule User do use MyApp.Web, :model schema "users" do field :email, :string field :first_name, :string belongs_to :role, Role has_many :comments, Com...
Livi asked 21/9, 2016 at 15:15

1

Solved

I want to display a range of dates (statistics) like: Dates | Count -------------------- "2016-09-01" | 0 "2016-09-02" | 0 "2016-09-03" | 0 "2016-09-04" | 0 "2016-09-05" | 0 "2016-09-06" | 12 "201...
Dhar asked 18/9, 2016 at 10:42

1

What is the easiest way to clone an Ecto model / record? I have a sample recipe model with many ingredients and embedded labels. Model defmodule App.Recipe do use App.Web, :model schema "recipe...
Counterblast asked 30/6, 2016 at 8:12

2

Solved

I have a User and Program model which have a many-to-many association. They create associations successfully, so that a User has many Programs (and vice versa), but now I need to remove the associa...
Otic asked 24/8, 2016 at 15:38

2

I have a couple of Ecto records. But I want to duplicate them (make them 100 times bigger) to play with big amount of records. How can I do that via ecto mechanisms?
Puttier asked 8/8, 2016 at 10:28

© 2022 - 2024 — McMap. All rights reserved.