From e61915fbb5b1a2ccfc0a6fe3fdc91dedfee6bd96 Mon Sep 17 00:00:00 2001 From: Yevgeniy Chaikin Date: Tue, 31 Oct 2017 19:32:12 +0200 Subject: [PATCH 1/4] move before_action snippet under .meta.rails.controller --- snippets/language-ruby-on-rails.cson | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/language-ruby-on-rails.cson b/snippets/language-ruby-on-rails.cson index 0f3bc3c..04eae5b 100644 --- a/snippets/language-ruby-on-rails.cson +++ b/snippets/language-ruby-on-rails.cson @@ -149,9 +149,6 @@ 'assert_template': 'prefix': 'aste' 'body': 'assert_template \'${1:template}\'' - 'before_action': - 'prefix': 'ba' - 'body': 'before_action :${1:method}${2:${3:, :only => ${4:[:${5:action}, :${6:action}]}}${7:, :except => ${8:[:${9:action}, :${10:action}]}}}' 'before_create': 'prefix': 'befc' 'body': 'before_create ' @@ -459,6 +456,9 @@ 'prefix': 'if' 'body': '<% if ${1:condition} %>\n $0\n<% end %>' '.meta.rails.controller': + 'before_action': + 'prefix': 'ba' + 'body': 'before_action :${1:method}${2:${3:, :only => ${4:[:${5:action}, :${6:action}]}}${7:, :except => ${8:[:${9:action}, :${10:action}]}}}' 'format (respond_with)': 'prefix': 'format' 'body': 'format.${1:html|xml|json|js|any} { $0 }' From 8ac4acf77f3bf7a63cc8a6f960770e8cb6764762 Mon Sep 17 00:00:00 2001 From: Yevgeniy Chaikin Date: Tue, 31 Oct 2017 19:34:53 +0200 Subject: [PATCH 2/4] add around_action and after_action snippets --- snippets/language-ruby-on-rails.cson | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/snippets/language-ruby-on-rails.cson b/snippets/language-ruby-on-rails.cson index 04eae5b..963b248 100644 --- a/snippets/language-ruby-on-rails.cson +++ b/snippets/language-ruby-on-rails.cson @@ -459,6 +459,12 @@ 'before_action': 'prefix': 'ba' 'body': 'before_action :${1:method}${2:${3:, :only => ${4:[:${5:action}, :${6:action}]}}${7:, :except => ${8:[:${9:action}, :${10:action}]}}}' + 'around_action': + 'prefix': 'ara' + 'body': 'around_action :${1:method}${2:${3:, :only => ${4:[:${5:action}, :${6:action}]}}${7:, :except => ${8:[:${9:action}, :${10:action}]}}}' + 'after_action': + 'prefix': 'afa' + 'body': 'after_action :${1:method}${2:${3:, :only => ${4:[:${5:action}, :${6:action}]}}${7:, :except => ${8:[:${9:action}, :${10:action}]}}}' 'format (respond_with)': 'prefix': 'format' 'body': 'format.${1:html|xml|json|js|any} { $0 }' From 7ce8fd531f61dbca47cd5765300fe69936966134 Mon Sep 17 00:00:00 2001 From: Yevgeniy Chaikin Date: Tue, 31 Oct 2017 19:39:10 +0200 Subject: [PATCH 3/4] add skip_before_filter snippet --- snippets/language-ruby-on-rails.cson | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snippets/language-ruby-on-rails.cson b/snippets/language-ruby-on-rails.cson index 963b248..4ecf135 100644 --- a/snippets/language-ruby-on-rails.cson +++ b/snippets/language-ruby-on-rails.cson @@ -480,6 +480,9 @@ 'session': 'prefix': 'sess' 'body': 'session[:${1:user}]$0' + 'skip_before_action': + 'prefix': 'skipba' + 'body': 'skip_before_action :${1:method}${2:${3:, :only => ${4:[:${5:action}, :${6:action}]}}${7:, :except => ${8:[:${9:action}, :${10:action}]}}}' '.meta.rails.routes': 'get :on => :member': 'prefix': 'get' From 068c902948c5b46971ed23aeb063bcbdc292dd38 Mon Sep 17 00:00:00 2001 From: Yevgeniy Chaikin Date: Tue, 31 Oct 2017 20:20:30 +0200 Subject: [PATCH 4/4] add snippets for 'sexy' validations --- snippets/language-ruby-on-rails.cson | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/snippets/language-ruby-on-rails.cson b/snippets/language-ruby-on-rails.cson index 4ecf135..2c65ce1 100644 --- a/snippets/language-ruby-on-rails.cson +++ b/snippets/language-ruby-on-rails.cson @@ -439,6 +439,30 @@ 'scope': 'prefix': 'scope' 'body': 'scope :${1:name}, ${2:joins(:${3:table}).}where(${4:\'${5:$3.${6:field}} = ?\', ${7:\'${8:value}\'}})' + 'validates :acceptance': + 'prefix': 'valida' + 'body': 'validates :${1:terms_of_service}, acceptance: ${2:true}$3' + 'validates :confirmation': + 'prefix': 'validc' + 'body': 'validates :${1:email}, confirmation: ${2:true}$3' + 'validates :exclusion': + 'prefix': 'valide' + 'body': 'validates :${1:subdomain}, exclusion: { in: %w(${2:www us ca jp})${3:, message: \'$4\'} }$5' + 'validates :format': + 'prefix': 'validf' + 'body': 'validates :${1:legacy_code}, format: { with: /$2/${3:, message: \'$4\'} }$5' + 'validates :inclusion': + 'prefix': 'validi' + 'body': 'validates :${1:size}, inclusion: { in: %w(${2:small medium large})${3:, message: \'$4\'} }$5' + 'validates :length': + 'prefix': 'validl' + 'body': 'validates :${1:name}, length: { ${2:option1}: ${3:value1}${4:, ${5:option2}: ${6:value2}} }$7' + 'validates :presence': + 'prefix': 'validp' + 'body': 'validates :${1:username}, presence: true$2' + 'validates :uniqueness': + 'prefix': 'validu' + 'body': 'validates :${1:email}, uniqueness: true$2' '.text.html.ruby': 'content_for': 'prefix': 'conf'