Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding a file in a Phoenix app script (Rails.root)

Is there something similar to Rails.root for Phoenix. Lets say I'd like to work with a configuration file in a Phoenix app. What is the convention for finding the file and path for use in a script?

like image 455
Elliot Larson Avatar asked Nov 26 '15 05:11

Elliot Larson


1 Answers

In case of Elixir this is not that easy as with Ruby, because your application is compiled - the compiled code resides in a different place than the source code.

The traditional place to put any additional resources for an Elixir/Erlang application is the priv directory alongside lib. Mix knows how to handle it, and expose it for the compiled code. You can access it at runtime either with :code.priv_dir(my_app) or with Application.app_dir(my_app, "priv").

like image 75
michalmuskala Avatar answered Sep 30 '22 09:09

michalmuskala