TextMate snippet for load_model methods in Rails controllers
1 2 def load_user 3 @user = User.find(params[:user_id]) if params[:user_id]
Here's a TextMate snippet, so you can just type: defmodel, TAB, user, TAB, and you're done.
Snippet:
1 2 def load_${1:model} 3 @$1 = ${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}.find(params[${2::$1_}id])${3: if params[:$1_id]} 4 end
Activation: defmodel
Scope: source.ruby.rails
I have this in the Ruby on Rails bundle, but you can put it anywhere. Its the scope that is important.