mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-12-11 08:00:53 +00:00
first commit of a million rails snippets, conditions missing, command implementation missing...
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: defcreate
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: def create - resource
|
||||
## condition: "meta.rails.controller"
|
||||
# --
|
||||
def create
|
||||
@${1:model} = ${2:${1:$(replace-regexp-in-string "_" "" (capitalize yas/text))}}.new(params[:$1])
|
||||
$0
|
||||
respond_to do |wants|
|
||||
if @$1.save
|
||||
flash[:notice] = '$2 was successfully created.'
|
||||
wants.html { redirect_to(@$1) }
|
||||
wants.xml { render :xml => @$1, :status => :created, :location => @$1 }
|
||||
else
|
||||
wants.html { render :action => "new" }
|
||||
wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user