diff --git a/snippets/language-ruby-on-rails.cson b/snippets/language-ruby-on-rails.cson index 0f3bc3c..2c65ce1 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 ' @@ -442,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' @@ -459,6 +480,15 @@ '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}]}}}' + '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 }' @@ -474,6 +504,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'