What is a changeset in phoenix elixir

From the documentation: Changesets allow filtering, casting, validation and definition of constraints when manipulating models.. There is an example of working with changesets in the introductory documentation in the Ecto module. The functions change/2 and cast/4 are the usual entry points for creating changesets, while the remaining functions are useful for manipulating them. Changesets are … Read more

What is Elixir Plug?

Is it an abstraction layer between the two Yes, exactly! Plug is meant to be a generic adapter for different web servers. Currently we support just Cowboy but there is work to support others. Plug also defines how different components should be plugged together. Similar to Rack in Ruby, WSGI in Python, Ring in Clojure, … Read more

Why is Elixir’s Access behaviour not a protocol?

As you’ve already mentioned, Access‘s implementation was changed to use Behaviours instead of Protocols. The reasoning was performance. Protocols are type/data based polymorphism, and are exclusive to Elixir. That means it lets you dispatch based on the data structure Behaviours are a typeless mechanism that don’t rely on a data structure, but the module as … Read more

Making a field unique in ecto

You want to use unique_constraint/3. This is not like Active Record because it is using the database to ensure uniqueness. Active Record would do a query for records with the same value and if any were returned then it would fail. This has a race condition where, if a value is inserted between fetching to … Read more

What is =~ operator in elixir

It’s not documented on that page, but it’s documented in Kernel.=~/2 that when the RHS is a string, =~ checks if LHS contains RHS: iex(1)> “foo” =~ “f” true iex(2)> “foo” =~ “o” true It does not implicitly convert RHS to regex: iex(3)> “foo” =~ “.” false If RHS is a regular expression, returns true … Read more

Inconsistent Functions behavior

Since 0.10.3 you need to put the partial application between parentheses preceded by the & operator. You won’t have any trouble with this version: iex> square = &(&1 * &1) iex> square.(5) 25 iex> cube = &(&1 * &1 * &1) iex> cube.(5) 125

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)