我正在尝试将布尔值传递给hidden_input。但是Postgrex似乎并不理解我试图传入的内容。
Postgrex expected a boolean, got "1". Please make sure the value you are passing matches the definition in your table or in your query or convert the value accordingly.
<%= inputs_for f, :users_leagues, fn ff -> %>
<%= hidden_input ff, :commissioner, value: 1 %>
<%= hidden_input ff, :user_id, value: assigns.current_user.id %>
<%= hidden_input ff, :league_id, value: 1 %>
<% end %>
如果只是传递true
,我也会收到此错误:Postgrex expected a boolean, got "value"
如何将布尔值传递给隐藏字段?
答案 0 :(得分:2)
我发现我做错了什么:
我的users_leagues模式设置如下:
schema "users_leagues" do
field :commissioner, :string
end
它应该像这样设置:
schema "users_leagues" do
field :commissioner, :boolean
end
匹配数据库记录。