Ruby on rails 设计:注册控制器不';不显示即时消息
我已经创建了注册控制器,该控制器覆盖Desive上的默认值。除了flash消息外,一切都很正常-当用户进行新注册时,我想在我的主页上重定向他,并向他显示一条有关正在发生的事情的flash消息,如下图所示:Ruby on rails 设计:注册控制器不';不显示即时消息,ruby-on-rails,ruby,flash,devise,flash-message,Ruby On Rails,Ruby,Flash,Devise,Flash Message,我已经创建了注册控制器,该控制器覆盖Desive上的默认值。除了flash消息外,一切都很正常-当用户进行新注册时,我想在我的主页上重定向他,并向他显示一条有关正在发生的事情的flash消息,如下图所示: class RegistrationsController < Devise::RegistrationsController def new super end def create resource = build_resource(params[:us
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消息通常是有效的,但不适用于这种情况
我错过了什么
谢谢您您必须使用不同的引号,否则div类会出错:
%div{:class => "alert alert-#{type == :notice ? 'success' : type} fadeout", "data-dismiss" => "alert"}
%div{:class => "alert alert-#{type == :notice ? 'success' : type} fadeout", "data-dismiss" => "alert"}