Take the 2-minute tour ×

I configured rails to work fine with Rails 3. I am trying to create a migration, and here it is its code:

class CreateObservations < ActiveRecord::Migration
  def change
    create_table :observations do |t|
      t.integer :user_id
      t.integer :start
      t.integer :end
      t.string :videoID
      t.string :event
      t.string :content

    add_index :observations, [:user_id, :created_at]


now when I run 'rake db:migrate' I get this strange error: why?

demo_app/test/factories/observations.rb:7:syntax error, unexpected tINTEGER, expecting keyword_end
demo_app/test/factories/observations.rb:12: syntax error, unexpected keyword_end, expecting $end

Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

I am NOT doing any testing now. Just development. so I run this:

 rake db:migrate RAILS_ENV=development

and I get the same error.

here is the code in the factory girl which I dont want to include!!!

FactoryGirl.define do
  factory :observation do
    user_id 1
    start 1
    end 1
    videoID "MyString"
    event "MyString"
    content "MyString"
share|improve this question
What's in demo_app/test/factories/observations.rb? –  ramblex Mar 25 '12 at 15:29
add comment

1 Answer

up vote 1 down vote accepted

It's probably because of using end field try to change it to something different

share|improve this answer
omg, I just noticed that. is there a way to change that without re creating the whole model?!? or changing loads of files? –  Test Test Mar 25 '12 at 15:33
@TestTest You could avoid it by carefully programming around it but it will generally be a pain in the ass. Better suck it up and change your model. –  Holger Just Mar 25 '12 at 15:36
rake db:drop && rake db:create && rake db:migrate should work –  Said Kaldybaev Mar 25 '12 at 15:36
yeah but I still need to delete my model right? (the views etc etc) –  Test Test Mar 25 '12 at 15:43
no, no need to delete your model, first rake db:drop, then delete end from migration then rake db:create && rake db:migrate –  Said Kaldybaev Mar 25 '12 at 15:46
show 4 more comments

Your Answer


