views:

47

answers:

2

I'm having huge problems with my populate.rake file - after importing my existing file from my Rails 2.3.5 installation, Rails 3 wants nothing to do with it. I'm getting tens (if not hundreds) of errors in my console, many of them for simple statements, and some even in the middle of a string of plaintext.

Has the syntax changed for Rails 3 populate or, perhaps do I need to install a gem/plugin for it?

Thanks very much.

+1  A: 

db-populate is a Rails plugin which uses a populate.rake file, it's not core Rails functionality so yes, you'd need a gem/plugin for it (http://github.com/ffmike/db-populate).

However, since you've upgraded to Rails 3, it might be a nice time to switch to using the built-in Rails seed functionality - that way it's easy to run rake db:setup which will create the db from database.yml, load the schema, and run seeds.rb or rake db:reset which does the same thing after dropping the db. Keeps you from having to maintain third-party code as well. Just food for thought. :)

jenjenut233
A: 

I found the problem after carefully reconstructing the populate.rake file from a copy. Some of the sample text I introduced into the file had quotes and these were interfering with the quotes belonging to the string itself.

Once Rails interprets the string as having ended, then it logically starts to return errors within the successive strings, which it is reading as interpretable code.

Once I removed all the quotes from within my strings during that reconstruction, the file started working. Thank you Ryan and JenJenut for your replies!

sscirrus