Merge pull request #540 from mclee/rails4

update snippets to fit strong parameters
This commit is contained in:
Louis Pilfold 2015-03-11 17:57:18 +00:00
commit 93d5c015bb

View File

@ -36,7 +36,7 @@ snippet crw
cattr_accessor :${0:attr_names} cattr_accessor :${0:attr_names}
snippet defcreate snippet defcreate
def create def create
@${1:model_class_name} = ${2:ModelClassName}.new(params[:$1]) @${1:model_class_name} = ${2:ModelClassName}.new($1_params)
respond_to do |format| respond_to do |format|
if @$1.save if @$1.save
@ -95,7 +95,7 @@ snippet defupdate
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id]) @${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
respond_to do |format| respond_to do |format|
if @$1.update_attributes(params[:$1]) if @$1.update($1_params)
flash[:notice] = '$2 was successfully updated.' flash[:notice] = '$2 was successfully updated.'
format.html { redirect_to(@$1) } format.html { redirect_to(@$1) }
format.xml { head :ok } format.xml { head :ok }
@ -105,6 +105,10 @@ snippet defupdate
end end
end end
end end
snippet defparams
def ${1:model_class_name}_params
params.require(:$1).permit()
end
snippet dele delegate .. to snippet dele delegate .. to
delegate :${1:methods}, to: :${0:object} delegate :${1:methods}, to: :${0:object}
snippet dele delegate .. to .. prefix .. allow_nil snippet dele delegate .. to .. prefix .. allow_nil