Using a primary key not named id with Ecto and Mysql

Problem

You would like to use a legacy or a database you don’t have control over, with Phoenix, but the primary key of the table it is not named ‘id’.

Solution

You can define the primary key using the @primary_key as in:

Taken from here

Starting Phoenix server in a different port than 4000

Problem

You would like start a phoenix application in a port different from the default 4000, by using something similar to the rails:

Solutin

You will need to change the config/dev.exs file to include the following:

and then start the server with:

Taken from the answer here

Request failed (404) ** (Mix) Package fetch failed and no cached copy available

Problem

You are trying to use hex for installing dependencies but when you are behind a proxy you get the following message:

Solution

You can use the following to set up hex (taken from the answer here:

Error: Brunch 2+ requires node v4.0+. Upgrade node or use older brunch for old node.js: npm i -g brunch@1

Problem

Trying to start a new phoenix application while your node installation is old you get the following error:

Solution

You will need to upgrade your node installation by following the steps below:

Updating Phoenix from 0.3.1 to 0.4.0

Problem

You would like to upgrade to the latest version of Phoenix 0.4.0 from the previous version of 0.3.1. When you try to update the dependencies and try to start phoenix again (mix phoenix.start) you get the following error:

Solution

After upgrading your Elixir version to the latest (1.0.0-rc1), and updating the path to your elixir installation so that it uses the new one, clear the dependencies from your project:

Change the dependency in your mix.exs file to be as the following:

and then get the dependencies again with:

after that you should be able to start your phoenix project with tne new version.