我在使用Devise保存註冊表單時遇到問題。我使用rails 3.1.1,ruby 1.9.2和設計1.4.8。另外,我正在使用mongoid 2.3.2。Rails註冊表格不保存
user.rb
class User
include Mongoid::Document
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
#fields in addition to Devise fields.
field :name
field :display_name
index :display_name, :unique=>true
field :gender
field :website
field :about
#referenced documents
has_many :accomplishments
has_many :projects
has_many :ranks
#self reference for followers and followees
references_and_referenced_in_many :followees, :class_name=>"User", :inverse_of=>:followers
references_and_referenced_in_many :followers, :class_name=>"User", :inverse_of=>:followees
#validations
validates_uniqueness_of :display_name, :message=>"Display name already exists.", :allow_nil=>true
validates_presence_of :name, :message=>" is required"
attr_accessible :email, :password, :password_confirmation, :name
end
我的註冊表單是非常簡單的爲好。
/views/devise/registrations/new.html.erd
<h2>Sign up</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<p>
<%= f.label :email %>
<div class="input">
<%= f.email_field :email %>
</div>
</p>
<p>
<%= f.label :password %>
<div class="input">
<%= f.password_field :password %>
</div>
</p>
<p>
<%= f.label :confirmation %>
<div class="input">
<%= f.password_field :password_confirmation %>
</div>
</p>
<p>
<%= f.label :name %>
<div class="input">
<%= f.text_field :name %>
</div>
</p>
<br/>
<p><%= f.submit "Sign up", :class => "btn primary" %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>
我的問題是,當我提出,我沒有得到任何錯誤,閃光燈告訴我,我成功地簽訂了協議。但是當你看一下mongo的用戶集合時,不存在任何文檔。我試圖讓我的用戶模型非常簡單,並相應地修改了註冊頁面,並且仍然以相同的結果結束。我正在尋找什麼來確定記錄不存儲的原因。有什麼想法可能會出錯?
此外,如果需要更多的細節或更好的解釋問題,我很樂意進一步深入。點擊下一步要檢查的磚牆來解決問題。
有這個相同的問題。這種行爲只發生在開發模式中嗎? – emkman