2016-12-29 79 views
0

使用Elixir &鳳凰框架在這裏。Phoenix Ecto驗證錯誤

我有一個註冊頁面,我在使用validate_confirmation函數驗證密碼&密碼確認字段。

def changeset(model, params \\ %{}) do 
    model 
    |> cast(params, @required_fields, @optional_fields) 
    |> validate_confirmation(:password) 
    |> validate_length(:firstName, min: 2) 
end 

如果我輸入的密碼不匹配,我得到一個錯誤no function clause matching in Gettext.dngettext/6在瀏覽器 - http://imgur.com/a/1uZ3N

我已經張貼在此之前最新的依賴關係。

完整的堆棧跟蹤可以在這裏找到 - http://pastebin.com/XLKav4cu

我在做什麼錯?

+0

您可以發佈完整的錯誤消息在外殼印刷(包括堆棧跟蹤)該請求之後? – Dogbert

+0

@Dogbert這裏是stacktrace - http://pastebin.com/XLKav4cu –

+0

你也可以發佈'web/views/error_helpers'和'web/templates/professional/form.html.eex'的源代碼嗎? – Dogbert

回答

1

您正在使用Ecto的舊式語法。現在,您需要轉換,然後傳遞給validate_required功能

def changeset(model, params \\ %{}) do 
    model 
    |> cast(params, [list of all fields]) 
    |> validate_required([list of required fields]) 
    |> validate_confirmation(:password) 
    |> validate_length(:firstName, min: 2) 
end 

https://hexdocs.pm/ecto/Ecto.html#module-changesets進一步的細節

+0

對不起,但錯誤仍然存​​在原樣。這裏是模型代碼 - http://pastebin.com/CF7SneDY –

+0

通過在這裏的每一步按照通過 - http://www.phoenixframework.org/blog/upgrading-from-11x-to-120 - 解決了問題 - 我是恢復舊項目,並沒有遵循升級新聞。 –