Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Devise - migrate output different from video - def self.up vs def change

Just been working through the tutorials and noticed that when I installed devise and setup the user model, my devise_create_users.rb file looked quite different:

class DeviseCreateUsers < ActiveRecord::Migration
  def self.up
    create_table(:users) do |t|
      t.database_authenticatable :null => false
      t.recoverable
      t.rememberable
      t.trackable

      # t.encryptable
      # t.confirmable
      # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
      # t.token_authenticatable


      t.timestamps
    end

    add_index :users, :email,                :unique => true
    add_index :users, :reset_password_token, :unique => true
  end

  def self.down
    drop_table :users
  end
end

With this format, where do I add the t.string for :first_name, :last_name etc.? And, will it be tracking all of the same information that's listed in the video?

3 Answers

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Luke Scoates you can add them below the line that says "create_table(:users) do |t|" and it should work correctly.

Thanks Jason! I've noticed that I was having problems because I'm running rails 4 - should I be learning on 4, or is it better to build an app using an earlier version that fits with the tutorials?

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Luke Scoates it's much better to follow along with an earlier version. There are changes between versions that you'll probably spend a long time figuring out which would really put a damper on learning, though it would be great for experience. We'll be redoing the Rails lessons shortly using Rails 4.