Commit 5b8201a2
Changed files (6)
app
views
devise
registrations
shared
app/helpers/application_helper.rb
@@ -1,8 +1,8 @@
module ApplicationHelper
def avatar_url(user)
- default_url = "#{root_url}assets/chefhat_profile.PNG"
- gravatar_id = Digest::MD5.hexdigest(user.email.downcase)
- "http://gravatar.com/avatar/#{gravatar_id}.png?&d=#{CGI.escape(default_url)}"
+ default_url = "#{root_url}assets/chefhat_profile.PNG"
+ gravatar_id = Digest::MD5.hexdigest(user.email.downcase)
+ "http://gravatar.com/avatar/#{gravatar_id}.png?&d=#{CGI.escape(default_url)}"
end
def gravatar_for(user, options = { size: 50 })
gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
app/helpers/devise_helper.rb
@@ -0,0 +1,25 @@
+module DeviseHelper
+ def devise_error_messages!
+ return "" if resource.errors.empty?
+
+ messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
+ sentence = I18n.t("errors.messages.not_saved",
+ :count => resource.errors.count,
+ :resource => resource.class.model_name.human.downcase)
+
+ html = <<-HTML
+ <div id="error_explanation">
+ <h2>#{sentence}</h2>
+ <ul>#{messages}</ul>
+ </div>
+ HTML
+
+ html.html_safe
+ end
+ def devise_flash
+ if controller.devise_controller? && resource.errors.any?
+ flash.now[:error] = flash[:error].to_a.concat(resource.errors.full_messages)
+ flash.now[:error].uniq!
+ end
+ end
+end
app/views/devise/registrations/new.html.erb
@@ -1,29 +1,24 @@
<% content_for :head do %>
- <script type="text/javascript">
- $(document).ready(function(){
- $('#accepted').click(function(){
- if( $('#accepted').is(':checked')){
- $('#submit-registration').removeAttr('disabled');
- }
- else{
- $('#submit-registration').attr('disabled', 'disabled');
- }
- });
- });
- </script>
- <% end %>
-
+<script type="text/javascript">
+$(document).ready(function(){
+ $('#accepted').click(function(){
+ if( $('#accepted').is(':checked')){
+ $('#submit-registration').removeAttr('disabled');
+ }
+ else{
+ $('#submit-registration').attr('disabled', 'disabled');
+ }
+ });
+});
+</script>
+<% end %>
<div class="row">
<div class="span12">
- <%= devise_error_messages! %>
-
<div class="row">
<div class="span6">
<img src="/assets/cakeside-logo.png" alt="" />
<h3>Why CakeSide?</h3>
- <p>
- CakeSide is a community dedicated to giving cake artists, bakers, creators, hobbyists, and of course cake lovers a place to share ideas and creations. Explore your creativity and find your inspiration. Resources shared here are all user driven.
- </p>
+ <p>CakeSide is a community dedicated to giving cake artists, bakers, creators, hobbyists, and of course cake lovers a place to share ideas and creations. Explore your creativity and find your inspiration. Resources shared here are all user driven.</p>
</div>
<div class="span6">
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :class=> 'form-horizontal') do |f| %>
app/views/layouts/_messages.html.erb
@@ -0,0 +1,23 @@
+<% devise_flash -%>
+<% if(flash.any?) -%>
+ <div class="row">
+ <div class="span12">
+ <% flash.each do |key, value| -%>
+ <% Array(value).uniq.each do |message| -%>
+ <div class="alert alert-<%= key %>">
+ <a class="close" data-dismiss="alert" href="#">×</a>
+ <h4 class="alert-heading"><%= key.to_s.titleize -%>!</h4>
+ <%= message %>
+ </div>
+ <% end -%>
+ <!--
+ <div class="alert alert-<%= key %>">
+ <a class="close" data-dismiss="alert" href="#">×</a>
+ <h4 class="alert-heading"><%= key.to_s.titleize -%>!</h4>
+ <%= value %>
+ </div>
+ -->
+ <% end -%>
+ </div>
+ </div>
+<% end -%>
app/views/layouts/application.html.erb
@@ -25,19 +25,7 @@
<body>
<%= render "shared/header" %>
<div class="container">
- <% if(flash.any?) -%>
- <div class="row">
- <div class="span12">
- <% flash.each do |key, value| -%>
- <div class="alert alert-<%= key %>">
- <a class="close" data-dismiss="alert" href="#">×</a>
- <h4 class="alert-heading"><%= key.to_s.titleize -%>!</h4>
- <%= value %>
- </div>
- <% end -%>
- </div>
- </div>
- <% end -%>
+ <%= render "layouts/messages" %>
<%= yield %>
</div> <!-- /container -->
<%= render "shared/footer" %>