3

I'm complete noob at PostgreSQL, Ruby on Rails..

I'm trying to follow this tutorial (WITHOUT rubymine) http://www.codeproject.com/Articles/575551/User-Authentication-in-Ruby-on-Rails#InstallingRubyMine4

I have as such this to migrate (001_create_user_model.rb):

class CreateUserModel < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.column :username, :string
      t.column :email, :string
      t.column :password_hash, :string
      t.column :password_salt, :string
    end
  end

  def self.down
    drop_table :users
  end
end

The error I'm getting goes like this:

syntax error, unexpected ':', expecting ';' or '\n'
        t.column...sers do |t|

...
C:131071:in 'disable_dll_transaction'
Task:TOP => db:migrate
2
  • that is some really old syntax you have there.... doesnt look like a good tutorial. Commented Sep 4, 2013 at 4:49
  • hmm, I tried the syntax below as well. Didn't work, same error. Commented Sep 8, 2013 at 19:17

1 Answer 1

1

What about this:

class CreateUserModel < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.string :username, :null => false
      t.string :email,:null => false
      t.string :password_hash, :null => false
      t.string :password_salt, :null => false
      t.timestamps
    end
  end

  def self.down
    drop_table :users
  end
end
Sign up to request clarification or add additional context in comments.

3 Comments

Besides the textual differences? I just picked out a random migration and converted it to that format. Not sure if Ahmad's migration is from an older version of Rails.
Not textual difference. His code is still valid according to ActiveRecord::Migration documentation. Your answer should be 'You can also use the column types as method calls, rather than calling the column method.' But it not solving the problem from code view.
Worth a shot, FWIW. Besides, we don't have much to go on. :)

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.