Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replaced deprecated error_messages_for

  • Loading branch information...
commit fcdfa955718726fb1412110008eacc8e52cae711 1 parent 168a686
@joneslee85 joneslee85 authored
Showing with 15 additions and 3 deletions.
  1. +15 −3 Snippets/form_for with errors.tmSnippet
View
18 Snippets/form_for with errors.tmSnippet
@@ -3,11 +3,23 @@
<plist version="1.0">
<dict>
<key>content</key>
- <string>${TM_RAILS_TEMPLATE_START_RUBY_EXPR}error_messages_for :${1:model}${TM_RAILS_TEMPLATE_END_RUBY_EXPR}
+ <string>&lt;%= form_for @${1:model} do |f| %&gt;
+ &lt;% if @${2:$1}.errors.any? %&gt;
+ &lt;div id="error_explanation"&gt;
+ &lt;h2&gt;&lt;%= pluralize(@${3:$1}.errors.count, "error") %&gt; prohibited this post from being saved:&lt;/h2&gt;
+
+ &lt;ul&gt;
+ &lt;% @post.errors.full_messages.each do |msg| %&gt;
+ &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt;
+ &lt;% end %&gt;
+ &lt;/ul&gt;
+
+ &lt;/div&gt;
+ &lt;% end %&gt;
-${TM_RAILS_TEMPLATE_START_RUBY_INLINE}form_for @${2:$1} do |f|${TM_RAILS_TEMPLATE_END_RUBY_INLINE}
$0
-${TM_RAILS_TEMPLATE_END_RUBY_BLOCK}</string>
+
+&lt;% end %&gt;</string>
<key>name</key>
<string>form_for with errors</string>
<key>scope</key>
Please sign in to comment.
Something went wrong with that request. Please try again.