1
0
Fork 0
mirror of synced 2024-12-25 08:13:20 -05:00
ultimate-vim/bundle/snipmate-snippets/ruby-rails/defcreate.snippet
2014-05-09 21:28:39 +02:00

14 lines
420 B
Text

def create
@${1:model_class_name} = ${2:ModelClassName}.new(params[:$1])
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${3}