我已经创建了覆盖默认设置的注册控制器。一切都运行良好,但闪现消息 - 当用户进行新注册时,我想在我的主页上重定向他并向他显示正在发生的事情的闪现消息,如下所示:
class RegistrationsController < Devise::RegistrationsController
def new
super
end
def create
resource = build_resource(params[:user])
# add custom create logic here
if params[:referrer_key].nil?
puts 'A'
puts resource.inspect
if resource.save
puts 'B'
if resource.active_for_authentication?
#flash[:notice] = "Welcome!" # doesn't work neither
Notification.welcome(@user).deliver unless @user.invalid? # overriding original methods
sign_in(@user)
redirect_to root_url, :notice => "Welcome!"
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
expire_session_data_after_sign_in!
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
render 'application/splash'
end
用户已注册,登录,通知邮件也已发送,但没有显示闪烁消息。
我如何显示闪存消息:
#flash-display
- flash.each do |type, msg|
%div{:class => "alert alert-#{type == :notice ? "success" : type} fadeout", "data-dismiss" => "alert"}
%button.close ×
= msg if msg.is_a?(String)
闪存消息通常有效,但不适用于这种情况。
我可能会错过什么?
谢谢