0

I am starting to play around with ruby and setting up my development environment.

I am referencing This Ruby on Rails 'Getting Started Guide' and am down to section 5.5 'Running a Migration'

The problem is when I run the following command

rake db:migrate

I get the following error

C:\Users\someuser\RubymineProjects\my_app>rake db:migrate 
rake aborted!
SyntaxError:C:/Users/someuser/RubymineProjects/my_app/db/migrate/20140718160751_create_articles.rb:4: syntax error, unexpected '[', expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
  t.string :[title
             ^
C:/Users/someuser/RubymineProjects/my_app/db/migrate/20140718160751_create_articles.rb:5: syntax error, unexpected ']', expecting keyword_end
  t.text] :text
         ^
C:in `disable_ddl_transaction'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Any idea what is causing this and how to fix it?

1
  • Can you post your migration file? It should be t.string :title Commented Jul 18, 2014 at 16:25

1 Answer 1

3

It looks like you have some extra brackets in your migration that don't belong there. The migration should look like:

class CreateArticles < ActiveRecord::Migration
  def change
    create_table :articles do |t|
      t.string :title
      t.text :text

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.