Mongodb和Devise

时间:2014-06-09 17:13:45

标签: ruby-on-rails devise mongoid

我在mongo数据库上使用了devise的实现。我需要在我的注册视图中显示下拉菜单,因此我添加了以下行:

<%= f.select :status, options_for_select(["Viewer", "Standard", "Tutor"])%>

我还添加了user.rb模型:

field :status, :type => String, :default => ""

但是当我检查数据库时,状态字段显示为空。

1 个答案:

答案 0 :(得分:0)

试试这个:

<%= f.select :status, [["Viewer","Viewer"], ["Standard","Standard"], ["Tutor","Tutor"]], { :include_blank => "Please select" }  %>