设计 - 任何方式来告诉它是什么类型的错误消息?

时间:2017-06-07 19:01:47

标签: ruby-on-rails devise ruby-on-rails-5

我正在使用rails 5.0。我目前正在登录时显示我的错误消息:

    <% if flash.count > 0 %>
      <div class="panel panel-danger">
        <div class="panel-heading" id="error_explanation">
          <div id="error_explanation">
            <h2>Errors prevented you from logging in</h2>
            <ul>
              <% flash.each do |name, msg| %>
              <li>
                <%= content_tag :div, msg, id: "flash_#{name}" %>
              </li>
              <% end %>
            </ul>
          </div>
        </div>
      </div>
      <% end %>

这非常适合登录时出现错误,但是当我退出时,它表示有错误阻止我使用用户已成功注销的消息登录。

有没有办法确定它是什么类型的邮件?就像失败与会话消息一样。然后我可以改变样式,使它们看起来不像是错误?

编辑:整页代码

      <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <title>VasttPM -
        <%= yield(:page_title) %></title>

      <!-- Include style per-controller - vendor plugins -->
      <%= stylesheet_link_tag params[:controller] if ::Rails.application.assets.find_asset("#{params[:controller]}.css") %>

      <!-- Main css styles -->
      <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>

      <!-- Main javascript files -->
      <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
      <%= csrf_meta_tags %>

    </head>

    <body class="login-body" style="background-color: #ffffff;">
      <div class='page-login' ng-cloak>

        <div class="container" style="margin:100px">
          <div class="row">
            <div class="col-md-6 col-md-offset-6 col-sm-6 col-sm-offset-3 col-xs-12">

              <% if flash.count > 0 %>
              <div class="panel panel-danger">
                <div class="panel-heading" id="error_explanation">
                  <div id="error_explanation">
                    <h2>Errors prevented you from logging in</h2>
                    <ul>
                      <% flash.each do |name, msg| %>
                      <li>
                        <%= content_tag :div, msg, id: "flash_#{name}" %>
                      </li>
                      <% end %>
                    </ul>
                  </div>
                </div>
              </div>
              <% end %>

              <div class="well animated fadeInDown">

                <p>Please login with your Username and Password Below</p>

                <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>

                <fieldset>
                  <div class="form-group">
                    <label for="username">Username</label>
                    <%= f.text_field :username, autofocus: true, :class => 'form-control' %>
                  </div>
                  <div class="form-group">
                    <%= f.label :password %>
                    <%= f.password_field :password, autocomplete: "off", :class => 'form-control' %>
                  </div>

                  <hr/>
                  <div class="form-group">
                    <%= f.submit "Log in", {:class => 'btn btn-primary btn-block'} %>

                  </div>
                </fieldset>
                <% end %>

              </div>
            </div>
          </div>
        </div>

      </body>

0 个答案:

没有答案