Commit ba0c3d60 by Thanh Hung Pham

Custome message css

parent 2ed9d395
...@@ -24,3 +24,36 @@ footer { ...@@ -24,3 +24,36 @@ footer {
.total_jobs { .total_jobs {
text-align: center; text-align: center;
} }
.errors_panel {
margin-top: 50px;
}
.alert-error {
background-color: #f2dede;
border-color: #eed3d7;
color: #b94a48;
text-align: left;
}
.alert-alert {
background-color: #f2dede;
border-color: #eed3d7;
color: #b94a48;
text-align: left;
}
.alert-success {
background-color: #dff0d8;
border-color: #d6e9c6;
color: #468847;
text-align: left;
}
.alert-notice {
background-color: #dff0d8;
border-color: #d6e9c6;
color: #468847;
text-align: left;
}
module DeviseHelper
def devise_error_messages!
return '' if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
html = <<-HTML
<div class="alert alert-error alert-danger"> <button type="button"
class="close" data-dismiss="alert">×</button>
#{messages}
</div>
HTML
html.html_safe
end
end
...@@ -6,7 +6,7 @@ class User < ApplicationRecord ...@@ -6,7 +6,7 @@ class User < ApplicationRecord
:recoverable, :rememberable, :trackable, :recoverable, :rememberable, :trackable,
:confirmable, :lockable :confirmable, :lockable
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, length: { maximum: 255 }, format: { with: VALID_EMAIL_REGEX } validates :email, length: { maximum: 255 }, format: { with: VALID_EMAIL_REGEX }, uniqueness: true
validates_presence_of :fullname, message: "can't be empty", unless: :skip_fullname_validation validates_presence_of :fullname, message: "can't be empty", unless: :skip_fullname_validation
validates_presence_of :password, message: "can't be empty", unless: :skip_fullname_validation validates_presence_of :password, message: "can't be empty", unless: :skip_fullname_validation
......
<%- provide(:title, 'Register') -%> <%- provide(:title, 'Register') -%>
<div class="well"> <div class="well">
<h2>Register</h2> <h2>Register</h2>
<%- if user_signed_in? -%> <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<p> <%= devise_error_messages! %>
Hi guys!
</p>
<%- else -%>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="form-group"> <div class="form-group">
<%= f.label :email %><br /> <%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, class: 'form-control' %> <%= f.email_field :email, autofocus: true, class: 'form-control' %>
</div> </div>
<div class="actions">
<%= f.submit "Confirm your email", class: 'btn btn-primary' %>
</div>
<% end %>
<%- end -%>
<div class="actions">
<%= f.submit "Confirm your email", class: 'btn btn-primary' %>
</div>
<% end %>
</div> </div>
...@@ -11,11 +11,14 @@ ...@@ -11,11 +11,14 @@
<body> <body>
<%= render 'layouts/header' %> <%= render 'layouts/header' %>
<div class="container"> <div class="container">
<% flash.each do |key, value| %> <div class="errors_panel">
<div class="alert alert-<%= key %>"> <% flash.each do |key, value| %>
<%= value %> <div class="alert alert-<%= key %>">
</div> <%= value %>
<% end %> </div>
<% end %>
</div>
<%= yield %> <%= yield %>
<%= render 'layouts/footer' %> <%= render 'layouts/footer' %>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment