这是我的痛苦和戏剧的延续......
跑过,匆匆处理:
- 我可以输入我的电子邮件进行注册!
- 我可以点击确认链接!
我被带到正确的页面以确认:
http://localhost:3000/user/confirmation?confirmation_token=jxOZQnyixE1PvnrptnYO
这就是问题所在...一旦我提交表单,我就会收到此错误:
ActiveRecord::RecordNotFound in ConfirmationsController#confirm_account
{"utf8"=>"✓",
"_method"=>"put",
"authenticity_token"=>"qUk6EDoR6N+V0h5O/jLKNZtl0hiaN/g9Gd5YdI2QhIU=",
"user"=>{"confirmation_token"=>"jxOZQnyixE1PvnrptnYO",
"password"=>"[FILTERED]",
"password_confirmation"=>"[FILTERED]"},
"commit"=>"Confirm Account"}
问题在第 10 行:
class ConfirmationsController < Devise::ConfirmationsController
def show
@user = User.find_by_confirmation_token(params[:confirmation_token])
if !@user.present?
render_with_scope :new
end
end
def confirm_account
@user = User.find(params[:user][:confirmation_token])
if @user.update_attributes(params[:user]) and @user.password_match?
@user = User.confirm_by_token(@user.confirmation_token)
set_flash_message :notice, :confirmed
sign_in_and_redirect("user", @user)
else
render :action => "show"
end
end
end
这是我的show.html.erb
<%= form_for(resource, :url => confirm_account_path) do |f| %>
<%= f.label :email %>
<%= @user.email %>
<%= f.hidden_field :confirmation_token %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation %>
<%= f.submit 'Confirm Account' %>
<%= link_to 'Home', root_url %>
<%= render :partial => 'devise/shared/links' %>
<% end %>
我已经为此哭了一个星期……我真的希望这是我的一个愚蠢的错误(同时我没有)。
如果您需要,我很乐意为您提供更多信息。为方便起见,您能否完整地描述您的答案-我是 Rails 新手!