Rename wants to format in respond_to blocks in ruby snippets
This commit is contained in:
parent
609ac9ecff
commit
34ead4e3bf
@ -616,14 +616,14 @@ snippet defcreate
|
|||||||
def create
|
def create
|
||||||
@${1:model_class_name} = ${2:ModelClassName}.new(params[:$1])
|
@${1:model_class_name} = ${2:ModelClassName}.new(params[:$1])
|
||||||
|
|
||||||
respond_to do |wants|
|
respond_to do |format|
|
||||||
if @$1.save
|
if @$1.save
|
||||||
flash[:notice] = '$2 was successfully created.'
|
flash[:notice] = '$2 was successfully created.'
|
||||||
wants.html { redirect_to(@$1) }
|
format.html { redirect_to(@$1) }
|
||||||
wants.xml { render :xml => @$1, :status => :created, :location => @$1 }
|
format.xml { render :xml => @$1, :status => :created, :location => @$1 }
|
||||||
else
|
else
|
||||||
wants.html { render :action => "new" }
|
format.html { render :action => "new" }
|
||||||
wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
|
format.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end${3}
|
end${3}
|
||||||
@ -632,9 +632,9 @@ snippet defdestroy
|
|||||||
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
||||||
@$1.destroy
|
@$1.destroy
|
||||||
|
|
||||||
respond_to do |wants|
|
respond_to do |format|
|
||||||
wants.html { redirect_to($1s_url) }
|
format.html { redirect_to($1s_url) }
|
||||||
wants.xml { head :ok }
|
format.xml { head :ok }
|
||||||
end
|
end
|
||||||
end${3}
|
end${3}
|
||||||
snippet defedit
|
snippet defedit
|
||||||
@ -645,41 +645,41 @@ snippet defindex
|
|||||||
def index
|
def index
|
||||||
@${1:model_class_name} = ${2:ModelClassName}.all
|
@${1:model_class_name} = ${2:ModelClassName}.all
|
||||||
|
|
||||||
respond_to do |wants|
|
respond_to do |format|
|
||||||
wants.html # index.html.erb
|
format.html # index.html.erb
|
||||||
wants.xml { render :xml => @$1s }
|
format.xml { render :xml => @$1s }
|
||||||
end
|
end
|
||||||
end${3}
|
end${3}
|
||||||
snippet defnew
|
snippet defnew
|
||||||
def new
|
def new
|
||||||
@${1:model_class_name} = ${2:ModelClassName}.new
|
@${1:model_class_name} = ${2:ModelClassName}.new
|
||||||
|
|
||||||
respond_to do |wants|
|
respond_to do |format|
|
||||||
wants.html # new.html.erb
|
format.html # new.html.erb
|
||||||
wants.xml { render :xml => @$1 }
|
format.xml { render :xml => @$1 }
|
||||||
end
|
end
|
||||||
end${3}
|
end${3}
|
||||||
snippet defshow
|
snippet defshow
|
||||||
def show
|
def show
|
||||||
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
||||||
|
|
||||||
respond_to do |wants|
|
respond_to do |format|
|
||||||
wants.html # show.html.erb
|
format.html # show.html.erb
|
||||||
wants.xml { render :xml => @$1 }
|
format.xml { render :xml => @$1 }
|
||||||
end
|
end
|
||||||
end${3}
|
end${3}
|
||||||
snippet defupdate
|
snippet defupdate
|
||||||
def update
|
def update
|
||||||
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
||||||
|
|
||||||
respond_to do |wants|
|
respond_to do |format|
|
||||||
if @$1.update_attributes(params[:$1])
|
if @$1.update_attributes(params[:$1])
|
||||||
flash[:notice] = '$2 was successfully updated.'
|
flash[:notice] = '$2 was successfully updated.'
|
||||||
wants.html { redirect_to(@$1) }
|
format.html { redirect_to(@$1) }
|
||||||
wants.xml { head :ok }
|
format.xml { head :ok }
|
||||||
else
|
else
|
||||||
wants.html { render :action => "edit" }
|
format.html { render :action => "edit" }
|
||||||
wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
|
format.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end${3}
|
end${3}
|
||||||
@ -752,8 +752,8 @@ snippet ra
|
|||||||
snippet ral
|
snippet ral
|
||||||
render :action => "${1:action}", :layout => "${2:layoutname}"
|
render :action => "${1:action}", :layout => "${2:layoutname}"
|
||||||
snippet rest
|
snippet rest
|
||||||
respond_to do |wants|
|
respond_to do |format|
|
||||||
wants.${1:html} { ${2} }
|
format.${1:html} { ${2} }
|
||||||
end
|
end
|
||||||
snippet rf
|
snippet rf
|
||||||
render :file => "${1:filepath}"
|
render :file => "${1:filepath}"
|
||||||
@ -886,8 +886,8 @@ snippet vp
|
|||||||
validates :${1:attribute}, :presence => true
|
validates :${1:attribute}, :presence => true
|
||||||
snippet vu
|
snippet vu
|
||||||
validates :${1:attribute}, :uniqueness => true
|
validates :${1:attribute}, :uniqueness => true
|
||||||
snippet wants
|
snippet format
|
||||||
wants.${1:js|xml|html} { ${2} }
|
format.${1:js|xml|html} { ${2} }
|
||||||
snippet wc
|
snippet wc
|
||||||
where(${1:"conditions"}${2:, bind_var})
|
where(${1:"conditions"}${2:, bind_var})
|
||||||
snippet wh
|
snippet wh
|
||||||
|
Loading…
Reference in New Issue
Block a user