我在我的应用程序中使用Devise gem,我想在flash中显示设计错误消息
我已经完成了这个
devise_helper.rb
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="logmod__tab-wrapper">
<div class="logmod__tab lgm-1">
<div class="logmod__heading">
<span class="logmod__heading-subtitle">Enter your personal details <strong>to create an acount</strong></span>
</div>
<div class="logmod__form">
<form accept-charset="utf-8" action="#" class="simform">
<div class="sminputs">
<div class="input full">
<label class="string optional" for="user-name">Email*</label>
<%= f.email_field :email, :class => 'string optional', :id => 'user-email', :placeholder => 'Email' %>
</div>
</div>
<div class="sminputs">
<div class="input string optional">
<label class="string optional" for="user-pw">Password *</label>
<%= f.password_field :password, :class => 'string optional', :id => 'user-pw', :placeholder => 'Password' %>
</div>
<div class="input string optional">
<label class="string optional" for="user-pw-repeat">Repeat password *</label>
<%= f.password_field :password_confirmation, :class => 'string optional', :id => 'user-pw-repeat', :placeholder => 'Repeat Password' %>
</div>
</div>
<div class="simform__actions">
<%= f.submit "Sign up", :class => 'sumbit' %>
<span class="simform__actions-sidetext">By creating an account you agree to our <a class="special" href="#" target="_blank" role="link">Terms & Privacy</a></span>
</div>
</form>
</div>
<div class="logmod__alter">
<div class="logmod__alter-container">
</div>
</div>
<% end %>
<%#= render "companies/shared/links" %>
</div>
<div class="logmod__tab lgm-2">
<div class="logmod__heading">
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<span class="logmod__heading-subtitle">Enter your email and password <strong>to sign in</strong></span>
</div>
<div class="logmod__form">
<form accept-charset="utf-8" action="#" class="simform">
<div class="sminputs">
<div class="input full">
<label class="string optional" for="user-name">Email*</label>
<%= f.email_field :email, :class => 'string optional', :id => 'user-email', :placeholder => 'Email' %>
</div>
</div>
<div class="sminputs">
<div class="input full">
<label class="string optional" for="user-pw">Password *</label>
<%= f.password_field :password, autocomplete: "off", :class => 'string optional', :id => 'user-pw', :placeholder => 'Password' %>
<span class="hide-password">Show</span>
</div>
<% if devise_mapping.rememberable? -%>
<div style="padding-left: 20px;">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</div>
<% end -%>
</div>
<div class="simform__actions">
<%= f.submit "Log in", :class => 'sumbit', :name => 'commit' %>
<span class="simform__actions-sidetext"><%= link_to "Forgot your password?", new_password_path(resource_name), :class => 'special' %><br /></span>
</div>
</form>
</div>
<div class="logmod__alter">
<div class="logmod__alter-container">
</div>
</div>
<% end %>
我在与sessions / new.html.erb相同的文件中使用登录和注册页面。
new.html.erb
<% flash.each do |key, value| %>
<% if key == 'notice' %>
<script>
$.growl.notice({ message: "<%= value %>" });
</script>
<% elsif key == 'error' || key == 'alert' %>
<script>
$.growl.error({ message: "<%= value %>" });
</script>
<% end %>
<!--<div class="alert alert-<%#= key %>"><%#= value %></div>-->
<% end %>
我在jquery插件调用jquery growl
中显示错误消息布局/ application.html.erb
{{1}}
我面临的问题是在登录标签中我能够显示flash消息但是当我尝试在注册表单中输入已经收到的电子邮件时,它会呈现一个没有css但显示flash消息的新页面并且没有通过jquery growl显示我在 application.html.erb 中提供的Flash消息