-
-
Save sahidursuman/cf2e4e555296d2b44dad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def field_with_errors(object, method, &block) | |
| if block_given? | |
| if object.errors[method].empty? | |
| content = with_output_buffer(&block) | |
| content.html_safe | |
| else | |
| content = with_output_buffer(&block) | |
| content_tag(:span, content, :class => "field_with_errors") | |
| end | |
| end | |
| end | |
| def textarea_with_errors(object, method, &block) | |
| if block_given? | |
| if object.errors[method].empty? | |
| content = with_output_buffer(&block) | |
| content.html_safe | |
| else | |
| content = with_output_buffer(&block) | |
| content = content.gsub(/class=\"#{method}_box\"/, "class=\"#{method}_box textarea_with_errors\"") | |
| content.html_safe | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment