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? -%>
<p>
Hi guys!
</p>
<%- else -%>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %> <%= devise_error_messages! %>
...@@ -18,6 +13,4 @@ ...@@ -18,6 +13,4 @@
<%= f.submit "Confirm your email", class: 'btn btn-primary' %> <%= f.submit "Confirm your email", class: 'btn btn-primary' %>
</div> </div>
<% end %> <% end %>
<%- 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">
<div class="errors_panel">
<% flash.each do |key, value| %> <% flash.each do |key, value| %>
<div class="alert alert-<%= key %>"> <div class="alert alert-<%= key %>">
<%= value %> <%= value %>
</div> </div>
<% end %> <% 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