Skip to content

Instantly share code, notes, and snippets.

@waleo
Created December 19, 2019 20:27
Show Gist options
  • Save waleo/1146da6298b29d14d2d52c501de594e2 to your computer and use it in GitHub Desktop.
Save waleo/1146da6298b29d14d2d52c501de594e2 to your computer and use it in GitHub Desktop.
# Some helpfuld sed commands for upgrading from Rails 2.3.18 to Rails 3.0.0.
# Not a complete list
# Written for OSX.
# Changelog:
# 2019/12/19: Initial commit
# DEPRECATED ENV VARS
sed -i '' -E "s|RAILS_ROOT|Rails.root.to_s|" app/**/*rb
sed -i '' -E "s|RAILS_ROOT|Rails.root.to_s|" config/*rb
sed -i '' -E "s|RAILS_ENV|Rails.env|" lib/**/*rake
sed -i '' -E "s|ENV\[\"RAILS_ENV\"\]|Rails.env|" lib/**/*rake
# New Action Mailers Interface
sed -i '' -E '/@sent_on/ d' app/mailers/*rb
# form_for should use <%= instead of <%
sed -i '' -E "s|<% form_for|<%= form_for|" app/views/**/**/*.html.erb
# Active Record method changes
sed -i '' -E "s|validates_presence_of(.*)|validates \1 , :presence => true|" app/models/*rb
sed -i '' -E "s|find\(:all\)|all|" app/models/*rb
sed -i '' -E "s|\.find\(:all)|.all|" app/**/*rb
sed -i '' -E "s|\.find\(:all.*:conditions => (.*))|.where(\1)|" app/**/rb
sed -i '' -E "s|\.find\(:all.*:conditions=>(.*))|.where(\1)|" app/**/*rb
sed -i '' -E "s|\.find\(:all\)|.all|" app/**/*rb
sed -i '' -E "s|\.find\(:all\)|.all|" app/views/**/*erb
sed -i '' -E "s|named_scope|scope|" app/models/**/*rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment