Getting stuck with Coherence (syntax error before: eol)

Hi there!

Anyone using Coherence here? Because I’m getting stuck with it. I open an issue on its official repo, but still not get any answer :frowning:

I created simple CRUD app called “Ideabox”, and trying to implement Coherence to it. Everything is going smooth, except I getting stuck when following this order :


For example, lets say you want to show a list of products for everyone visiting the site, but only want authenticated users to be able to create, update, and delete products. You could do the following:

defmodule MyProject.ProductController do
  use MyProject.Web, :controller
  alias MyProject.Product

Coherence.Authentication.Session, [protected: true] when action != :index

----------------

Apparently, this syntax Coherence.Authentication.Session, [protected: true] when action != :index, create this error :

$ mix phoenix.server

== Compilation error on file web/controllers/idea_controller.ex ==
** (SyntaxError) web/controllers/idea_controller.ex:5: syntax error before: eol
    (elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1

I think I misplaced that syntax, but I just following the readme.

Any help would be greatly appreciated :slight_smile:
Thank you

You are probably missing the word plug:

plug Coherence.Authentication.Session, [protected: true] when action != :index

The error message will be slightly better in the next Elixir version. :slight_smile:

1 Like

Wow, thanks! It works @josevalim :smiley:
Thank you