Over a million developers have joined DZone.


DZone's Guide to


· ·
Free Resource
Emacs lisp macro for rails development to reverse the order of the columns in rename_column
Could use this approach to automatically rewrite most of the migration's "down"

(defun rails-reverse-rename-column ()
  "In a rails migration, from point to end of buffer, reverse the order of renamed columns"
    (while (re-search-forward "rename_column *\"\\([^\"]*\\)\" *, *\"\\([^\"]*\\)\" *, *\"\\([^\"]*\\)\" *$" nil t)
       (replace-match "rename_column \"\\1\", \"\\3\", \"\\2\""))))

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}