Skip to content

Commit 94ca312

Browse files
committed
changed flash error display logic, added a helper for handling flash css selectors
1 parent 9c7583e commit 94ca312

File tree

4 files changed

+34
-22
lines changed

4 files changed

+34
-22
lines changed

app/assets/stylesheets/application.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
*/
1414

1515
body { padding-top: 70px; }
16+
.alert { margin-top: 10px; }

app/helpers/application_helper.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
module ApplicationHelper
2+
3+
def flash_class(type)
4+
case type
5+
when :alert
6+
"alert-danger"
7+
when :notice
8+
"alert-info"
9+
else
10+
""
11+
end
12+
end
213
end
Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
1-
<h2>Sign up</h2>
1+
<div class="row">
2+
<div class="col-sm-5 col-sm-offset-3">
3+
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: {class: "well"}) do |f| %>
24

3-
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
45
<%= devise_error_messages! %>
5-
<div><%= f.label :first_name %><br />
6-
<%= f.text_field :first_name %></div>
76

8-
<div><%= f.label :last_name %><br />
9-
<%= f.text_field :last_name %></div>
10-
11-
<div><%= f.label :profile_name %><br />
12-
<%= f.text_field :profile_name %></div>
13-
14-
<div><%= f.label :email %><br />
15-
<%= f.email_field :email, :autofocus => true, class: "form-control" %></div>
16-
17-
<div><%= f.label :password %><br />
18-
<%= f.password_field :password %></div>
19-
20-
<div><%= f.label :password_confirmation %><br />
21-
<%= f.password_field :password_confirmation %></div>
22-
23-
<div><%= f.submit "Sign up" %></div>
7+
<fieldset>
8+
<legend>Sign up</legend>
9+
<%= f.input :first_name %>
10+
<%= f.input :last_name %>
11+
<%= f.input :profile_name %>
12+
<%= f.input :email %>
13+
<%= f.input :password %>
14+
<%= f.input :password_confirmation %>
15+
16+
<div><%= f.button :submit, "Sign up" %></div>
17+
</fieldset>
2418
<% end %>
2519

2620
<%= render "devise/shared/links" %>

app/views/layouts/application.html.erb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@
3838
</nav>
3939

4040
<div class="container">
41-
<p class="notice"><%= notice %></p>
42-
<p class="alert"><%= alert %></p>
41+
<% flash.each do |type, message| %>
42+
<div class="alert alert-dismissable <%= flash_class type %>">
43+
<button type="button" class="close" data-dismiss="alert"
44+
aria-hidden="true">&times;
45+
</button>
46+
<%= message %>
47+
</div>
48+
<% end %>
4349

4450
<%= yield %>
4551
</div>

0 commit comments

Comments
 (0)