Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Support/bin/insert_add_column_or_create_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Support/bin/intelligent_migration_snippet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down