emacs-railsのsinippet機能
僕は、emacsを使っており、rails開発のためにemacs-railsをセットアップしています。そこで便利なsnippet機能があることを知りました。覚える方が面倒ということもあるので、臨機応変に使えば良いと思います。
※アングルブラケット(<>)およびパイプライン(|)は、全角になっています。
キー入力 | 展開結果 |
---|---|
w[Tab] | attr_writer : |
while[Tab] | while condition |
tim[Tab] | times { |n| } |
ha[Tab] | { : } |
:[Tab] | :key => 'value' |
dir[Tab] | Dir.glob(glob) { |file| } |
meta[Tab] | <meta name="name" content="content"/> |
lia[Tab] | <%= link_to "text", :action => "index" %> |
bf[Tab] | before_filter :filter |
rp[Tab] | render :partial => 'item' |
rpc[Tab] | render :partial => 'item', :collection => items |
rea[Tab] | redirect_to :action => 'index' |
recai[Tab] | redirect_to :controller => 'items', :action => 'show', :id => item |
ve[Tab] | validates_exclusion_of :attribute |
vl[Tab] | validates_length_of :attribute, :within => 20 |
nr[Tab] | @item.new_record? |
tcl[Tab] | t.column :title, :string |
ct[Tab] | create_table :users do |t| tcls end |
hmt[Tab] | has_many :objects, :through => :table |
logd[Tab] | logger.debug 'message' |
最後のlogdが一番使いますかね。