简体   繁体   English

Country_select Devise中的宝石

[英]Country_select gem in Devise

i am new in rails , tell plz why this code does not work i use the gem Devise for registration, I want to let the user select his country ( with gem country_select ) and when i register new user i put the form: 我是新手,请告诉plz为什么此代码不起作用,我使用gem Devise进行注册,我想让用户选择他的国家(使用gem country_select),当我注册新用户时,我填写以下表格:

<div id='maintitle'><h1>Sign up</h1></div>

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
...
<div class='some_fild'>Email*<br />
<%= f.email_field :email %></div>
....
<div class='some_fild'>Confirm<br />
<%= f.password_field :password_confirmation %></div>

???? <---

<div><%= f.submit "Sign up" %></div>

I put in my 'user' db table column 'country' 我把我的“用户” db表列“国家”

what string i must put instead of "????<---" to this select seva in my DB in column 'country' ? 我必须在数据库“国家/地区”中的select seva中输入什么字符串而不是“ ???? <---”?

i think something like that: 我认为是这样的:

<%= f.country_select :country, 'select' %>

but it does not work 但它不起作用

You need to provide the model and the attribute you want to set - on that form, your model instance is stored inside resource , so you'd need this: 您需要提供要设置的模型和属性-在该表单上,模型实例存储在resource内部,因此您需要:

I used the example from the README , which doesn't make any mention of how to use it inside a form - I'd assume it's the same. 我使用了README中的示例该示例未提及如何在表单中使用它-我认为它是相同的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM