0

入力したキーワードが Recaptcha で問題ない場合、常にこの空白のフラッシュ メッセージがポップアップ表示されます。なんで?どうすればこれを修正できますか?

ここに画像の説明を入力

ルート

devise_for :users, :controllers => { :registrations => "registrations" }

registrations_controller.rb

def create
    if verify_recaptcha
        super
        flash.delete(:recaptcha_error)
        else
        build_resource
        clean_up_passwords(resource)
        flash.delete(:recaptcha_error)
        flash[:alert] = "Typed keyword is not correct!"
        render :template => '/registrations/new' 
    end
end

フラッシュ用に表示

<% flash.each do |name, msg| %>
  <div class="alert alert-<%= name == :notice ? "success" : "error" %>">
    <a class="close" data-dismiss="alert">&#215;</a>
    <%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
  </div>
<% end %>
4

1 に答える 1

1

フラッシュメッセージをすぐに使用する方法で使用flash.now[:alert]または:alertオプションを使用します。render

例:

render :template => '/registrations/new', :alert => "Typed keyword is not correct!"
于 2013-01-28T05:01:01.590 に答える