0
我遵循Phoenix編程書籍,但使用HAML作爲模板引擎。當渲染新temmplate創建新的用戶我得到這個錯誤:assign @chageset在Phoenix中使用HAML時eex模板不可用
assign @chageset not available in eex template.
我使用克里斯·麥科德的Phoenix_HAML並沒有配置好了一切。
控制器完全按照書中所述:
defmodule Rumbl.UserController do
use Rumbl.Web, :controller
def index(conn, _params) do
users = Repo.all(Rumbl.User)
render conn, "index.html", users: users
end
def show(conn, %{"id" => id}) do
user = Repo.get(Rumbl.User, id)
render conn, "show.html", user: user
end
alias Rumbl.User
def new(conn, _params) do
changeset = User.changeset(%User{})
render conn, "new.html", changeset: changeset
end
end
而且模板
%h1 New User
= form_for @chageset, user_path(@conn, :create), fn f ->
%div.form-group
= text_input f, :name, placeholder: "Name", class: "form-control"
%div.form-group
= text_input f, :username, placeholder: "Username", class: "form-control"
%div.form-group
= password_input f, :password, placeholder: "Password", class: "form-control"
= submit "Create User", class: "btn btn-primary"
- end
缺少什麼嗎?
'@ chageset'中的錯字? – Dogbert
難以置信......對不起......這是錯字...... –