chrisdel101
Checking changeset for changes causes changed? undefined error
I want to check if my changeset has changes in a true/false way. changset.changes returns %{} when empty, which is truthy, but I need that to be falsy here.
like: if changeset.has_change do...
I thought changed? would be the way but it doesn’t work for me.
How do I check the version of ecto? I’ve can’t find that info anywhere.
# user is a struct
iex(66)> changeset = Ecto.Changeset.change(user, %{id: 10})
#Ecto.Changeset<
action: nil,
changes: %{id: 10},
errors: [],
data: #User<>,
valid?: true
iex > Ecto.Changeset.changed?(changeset, :id)
function Ecto.Changeset.changed/2 is undefined or private
Try another way using phoenix changeset
iex(78)> x = change_user(user, %{last_name: "smith"})
#Ecto.Changeset<
action: nil,
changes: %{last_name: "smith"},
errors: [],
data: #User<>,
valid?: true
>
iex(79)> Ecto.Changeset.changed?(x, :last_name)
** (UndefinedFunctionError) function Ecto.Changeset.changed?/2 is undefined or private.
Is there another way I can do this? I guess checking for an empty map?
Marked As Solved
benwilson512
Author of Craft GraphQL APIs in Elixir with Absinthe
mix deps and then look to see what version of ecto is output.
Popular in Questions
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database.
Dep...
New
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
As a follow up to my earlier question:
I have the code compiling and running but not getting a successful login from the rest server. ...
New
What is most correct way to open, read and parse JSON file with poison?
For example if we have example.json file in root of some projec...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Other popular topics
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode.
The solution seems to be, in a hyphena...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
I tried installing
elixir 1.11.2
erlang 23.3.4
via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them ...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New








