Skip to content

Commit

Permalink
Better error messages on password reset
Browse files Browse the repository at this point in the history
  • Loading branch information
jadehopepunk committed Jul 23, 2014
1 parent 1405654 commit 00f06a7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/helpers/reader_helper.rb
Expand Up @@ -200,5 +200,26 @@ def css_for_readers_groups readers
}.join("\n")
end

def error_messages_except(record, excluded_fields)
errors = errors_except(record, excluded_fields)
unless errors.empty?
error_nodes = errors.map do |key, value|
content_tag(:li, content_tag(:strong, key.humanize.titleize) + ": #{value}")
end
content_tag(:ul, error_nodes.join("\n"), :class => 'error_list')
end
end

private

def errors_except(record, excluded_fields)
results = {}
record.errors.each do |key, value|
unless excluded_fields.include?(key.to_sym)
results[key] = value
end
end
results
end
end

1 change: 1 addition & 0 deletions app/views/password_resets/edit.html.haml
Expand Up @@ -7,6 +7,7 @@
%strong
= t('reader_extension.sorry').titlecase
= t('reader_extension.form_problem') + '.'
= error_messages_except @reader, [:password, :password_confirmation]

= hidden_field_tag :id, params[:id]
= hidden_field_tag :confirmation_code, @reader.perishable_token
Expand Down

0 comments on commit 00f06a7

Please sign in to comment.