public
Description: Ruby on Rails TextMate bundle [Learn it with PeepCode - http://peepcode.com/products/textmate-for-rails-2]
Homepage: http://groups.google.com/group/rubyonrails-textmate
Clone URL: git://github.com/drnic/ruby-on-rails-tmbundle.git
Click here to lend your support to: ruby-on-rails-tmbundle and make a donation at www.pledgie.com !
ruby-on-rails-tmbundle / Snippets / def create - resource.tmSnippet
100644 31 lines (30 sloc) 0.909 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>content</key>
  <string>def create
  @${1:model} = ${2:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}.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 =&gt; @$1, :status =&gt; :created, :location =&gt; @$1 }
    else
      wants.html { render :action =&gt; "new" }
      wants.xml { render :xml =&gt; @$1.errors, :status =&gt; :unprocessable_entity }
    end
  end
end
</string>
  <key>name</key>
  <string>def create - resource</string>
  <key>scope</key>
  <string>meta.rails.controller</string>
  <key>tabTrigger</key>
  <string>defcreate</string>
  <key>uuid</key>
  <string>54F61419-001F-4B71-83AC-8DC633694AF0</string>
</dict>
</plist>