0

We're trying to rename the columns of DB to rails conventions:

class MakeRailsy < ActiveRecord::Migration def change # Classes rename_table :Classes, :classes_ rename_table :classes_, :classes rename_column :classes, :ClassID, :id rename_column :classes, :ClassNO, :class_no rename_column :classes, :SE, :se rename_column :classes, :EE, :ee rename_column :classes, :CE, :ce rename_column :classes, :MBA, :mba rename_column :classes, :CS, :cs rename_column :classes, :AM, :am rename_column :classes, :ESL, :esl rename_column :classes, :U_G, :u_g %w(ClassName DepartmentID SectionNumber InstructorID Units Location DaysAndTimes Notes Description).each do |column| rename_column :classes, column, column.underscore end 

But this throws an error:

-- rename_column(:classes, "ClassName", "class_name") -> 0.0089s --  ([]) rake aborted! StandardError: An error has occurred, all later migrations canceled: undefined method ` ' for #<MakeRailsy:0x007ffa718e1160>/Users/kellyprice/git/transcript_archives/db/migrate/20150401225004_make_railsy.rb:19:in `block in change' /Users/kellyprice/git/transcript_archives/db/migrate/20150401225004_make_railsy.rb:18:in `each' /Users/kellyprice/git/transcript_archives/db/migrate/20150401225004_make_railsy.rb:18:in `change' NoMethodError: undefined method ` ' for #<MakeRailsy:0x007ffa718e1160> /Users/kellyprice/git/transcript_archives/db/migrate/20150401225004_make_railsy.rb:19:in `block in change' /Users/kellyprice/git/transcript_archives/db/migrate/2015040122500 

To try and rule out scope/syntax errors I tried, to no avail:

self.rename_column(:classes, column, column.underscore) 

And, if you flatten the loop and call rename_column manually, it seems to work.

3
  • I believe there is a typo in SectionNumber. It reads now, SectionMumber, with an M. Commented Apr 3, 2015 at 20:01
  • provide the entire migration named 20150401225004_make_railsy so we can take a lot at line 19 where the error is (read the error message) Commented Apr 3, 2015 at 20:22
  • @kwarrick, you're correct, but even when I fix that, it throws the same error. Commented Apr 3, 2015 at 21:00

2 Answers 2

2

You've got a unicode space in your file that Ruby has decided is a method call. It's one of these: http://www.fileformat.info/info/unicode/char/2002/index.htm

If you copy the space from the error message and search replace with a regular space, I think it should fix it.

Sign up to request clarification or add additional context in comments.

Comments

0

It would appear that there are copy and pasted en space's in that loop.

A quick search and replace:

:%s/ / /g 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.