amir baqdadi
amir baqdadi

Reputation: 174

Phoenix.Router.NoRouteError for assets

in elixir i try to create project under umbrella with this command

mix phx.new my_project --umbrella

in apps directory try to install phoenix project with this command

mix phx.new phx_project --no-ecto

and trye to add assets with new structure under the assets directory and new file with bar.css and use it on front end with :

<%= Routes.static_path(@conn, "/ja/bee/foo/bar.css") %>

I got nothing found.

but with this

<%= Routes.static_path(@conn, "/css/app.css") %>

it's ok .

Upvotes: 0

Views: 1219

Answers (2)

amir baqdadi
amir baqdadi

Reputation: 174

I tried to put my assets (js, css, images) under the assets directory but the real place, it is in fact under the assets/static directory. Personally I think this is not a good place why? Because in assets directory we have directories like css, js directory.

Upvotes: 0

Justin Wood
Justin Wood

Reputation: 10061

In your endpoint.ex file, you will have a section that looks something like

  plug Plug.Static,
    at: "/", from: :attendance_web, gzip: false,
    only: ~w(css fonts images js favicon.ico robots.txt)

You will need to add the ja directory to the list in the :only key. Then make sure your ja directory is beside your css directory.

Upvotes: 1

Related Questions