Skip to content

Instantly share code, notes, and snippets.

@kangkyu
Created February 2, 2015 21:06
Show Gist options
  • Save kangkyu/90bda70e68af80b6274b to your computer and use it in GitHub Desktop.
Save kangkyu/90bda70e68af80b6274b to your computer and use it in GitHub Desktop.
dismissible form error message in Rails
- if @task.errors.any?
= content_tag(:div, class: ["alert", "alert-danger", "alert-dismissible"], role: "alert", id: "error-explanation") do
= content_tag(:button, class: "close", type: "button", "data-dismiss"=> "alert") do
= content_tag(:span, escape_once("×"), "aria-hidden"=> "true")
= content_tag(:span, "Close", class: "sr-only")
%p= pluralize(@task.errors.count, "error") + " prohibited this user from being saved"
%ul
- @task.errors.full_messages.each do |msg|
%li= msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment