Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix migration snippets for Rails 3.1 so they can find def down as well as def self.down #41

Open
wants to merge 1 commit into from

1 participant

@james

I'm not sure if I've covered them all, but this has fixed mtab-> and mcol-> in migrations for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 21, 2011
  1. @james
This page is out of date. Refresh to see the latest.
View
2  Support/bin/insert_add_column_or_create_table.rb
@@ -25,7 +25,7 @@ def unprepend(text, prefix)
end
# Find 'self.down' method
-if self_down = buffer.find { /^(\s*)def\s+self\.down\b/ }
+if self_down = buffer.find { /^(\s*)def\s+(self\.|)down\b/ }
indentation = self_down[1]
# Find the matching create_table clause in the schema.rb file
View
2  Support/bin/intelligent_migration_snippet.rb
@@ -94,7 +94,7 @@ def insert_migration(snippet, text)
# find the beginning of self.down and insert down code, this is hardly robust.
# assuming self.down is after self.up in the class
lines.each_with_index do |line, i|
- if line =~ /^\s*def\s+self\.down\b/
+ if line =~ /^\s*def\s+(self\.|)down\b/
lines[i, 1] = [lines[i], down_code]
break
end
Something went wrong with that request. Please try again.