我是 Rails 新手,我正在尝试在注册时添加电子邮件确认。我目前收到此错误。
(任何冗长且易于理解的答案的加分。 )
路由错误
没有路由匹配 {:action=>"edit", :controller=>"email_activations", :id=>false}
配置/路由.rb
LootApp::Application.routes.draw do
get "password_resets/new"
get "sessions/new"
resources :users
resources :sessions
resources :password_resets
resources :email_activations
root to: 'static_pages#home'
应用程序/邮件程序/user_mailer.rb
class UserMailer < ActionMailer::Base
def registration_confirmation(user)
@user = user
mail(:to => user.email, :subject => "registered", :from => "alain@private.com")
end
end
应用程序/控制器/email_activations_controller.rb
class EmailActivationsController < ApplicationController
def edit
@user = User.find_by_email_activation_token!(params[:id])
@user.email_activation_token = true
redirect_to root_url, :notice => "Email has been verified."
end
end
app/views/user_mailer/registration_confirmation.html.haml
请确认您的电子邮件地址!
= edit_email_activation_url(@user.email_activation_token)