我试图在不使用内置设备确认控制器的情况下确认用户帐户,但我碰巧得到以下错误“未初始化的常量确认控制器”。以下是我的确认控制器类。
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.has_password?
@user = User.confirm_by_token(@user.confirmation_token)
flash[:notice] = "Hi " + @user.first_name + " your email has been verified. You can now start shopping and recommending other users to your supplier networks."
redirect_to @user
else
render :action => "show"
end
end
end
在我的routes.rb文件中,我有以下内容:
devise_for :users, :controllers => { :confirmations => "confirmations" } do
match "confirm_account", :to => "confirmations#confirm_account"
end
最后我有以下部分内容:
<p>Welcome <%= @user.first_name %>,</p><br/>
<%= form_for(resource, :url => confirm_account_path) do |f| %>
<%= f.label :email %>
<%= @user.email %>
<%= f.hidden_field :confirmation_token %>
<%= f.submit 'Confirm Account' %>
<p>Thank you for joining. Before you can purchase any item from your supplier or shared network, you will need to confirm your account first. Please follow the link below in order to confirm your account.</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p><br/>
<p>Yours faithfully.</p>
<%end%>