I have my controller as bellow
defmodule Ceecare.SearchController do
use Ceecare.Web, :controller
alias Ceecare.{Repo, Review}
def index(conn, _params) do
reviews = Review
|> Review.by_published(true)
|> Review.order_by_date(:desc)
|> Repo.all()
|> Repo.preload([:category])
conn
|> render("index.json", reviews: reviews)
end
end
and my search_view.ex as below
defmodule Ceecare.SearchView do
use Ceecare.Web, :view
def render("index.json", %{reviews: reviews}) do
%{data: render_many(reviews, __MODULE__, "review.json")}
end
def render("show.json", %{review: review}) do
%{data: render_one(review, __MODULE__, "review.json")}
end
def render("review.json", %{review: review}) do
%{
id: review.id,
title: review.title
}
end
end
but i keep getting Could not render "review.json" for Ceecare.SearchView, please define a matching clause for render/2 or define a template at "web/templates/search". No templates were compiled for this module. Assigns:
I have deleted the build and recompiled and it’s the same.
I have google this and the solution i saw points to the same code i’ve written.
I’m using elixir 1.4.4 and phoenix 1.2.0
Thanks.