【发布时间】:2015-04-16 08:47:33
【问题描述】:
我正在尝试在设计注册中添加国家/地区选择,我使用来自https://github.com/stefanpenner/country_select#example 的 country_select gem
这里解释了使用country_select("user", "country")使用模型和属性作为参数的简单用法:
问题:当我按下提交按钮时,用户被创建并且一切都很好,除了国家列没有我选择的数据
目的:提交注册后,我想将我从注册表单中选择的国家/地区插入数据库(表:用户,列:国家/地区)
sign_up.html.erb
<h2><center>Sign up</center></h2>
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= f.error_notification %>
<div class="form-inputs" style="float; margin:0 auto;width:35%">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :password, required: true %>
<%= f.input :password_confirmation, required: true %>
<%= f.label :country %>
<%= country_select("user", "country") %> <<-- My model's name is user.rb and in my users table has a country column
</div>
<div class="form-actions" style="float; margin:0 auto;width:10%">
<%= f.button :submit, "Sign up" %>
</div>
<% end %>
**我的模型名称是 user.rb,在我的 users 表中有一个国家列
感谢提前
【问题讨论】:
-
看起来你的控制器有问题。结帐:stackoverflow.com/questions/16471498/…
-
@jonsnow 我正在关注你的链接,现在我已经解决了,我应该发布这个问题的答案
-
为什么不呢,把它贴出来给你的问题增加更多的价值。 ;)
标签: mysql ruby-on-rails ruby devise