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

Miralina Stewart
Miralina Stewart
1,549 Points

Generating User Authentication System - rake db:migrate does nothing.

Hi,

I'm not sure where I went wrong! I added the new fields to the DeviseCreateUsers table, and then attempted to migrate. However, nothing happens... and when I type rake routes this is what I get:

miralinastewart:~/projects/treebook> rake routes statuses GET /statuses(.:format) statuses#index POST /statuses(.:format) statuses#create new_status GET /statuses/new(.:format) statuses#new edit_status GET /statuses/:id/edit(.:format) statuses#edit status GET /statuses/:id(.:format) statuses#show PUT /statuses/:id(.:format) statuses#update DELETE /statuses/:id(.:format) statuses#destroy root / statuses#index

As you can see, the devise table is completely missing. Any help greatly appreciated!

Miralina Stewart
Miralina Stewart
1,549 Points

here is the ######_devise_create_users.rb ... is that the migration file?

  class DeviseCreateUsers < ActiveRecord::Migration
  def change
  create_table(:users) do |t|
  t.string :first_name
  t.string :last_name
  t.string :profile_name

  ## Database authenticatable
  t.string :email,              :null => false, :default => ""
  t.string :encrypted_password, :null => false, :default => ""

  ## Recoverable
  t.string   :reset_password_token
  t.datetime :reset_password_sent_at

  ## Rememberable
  t.datetime :remember_created_at

  ## Trackable
  t.integer  :sign_in_count, :default => 0
  t.datetime :current_sign_in_at
  t.datetime :last_sign_in_at
  t.string   :current_sign_in_ip
  t.string   :last_sign_in_ip

  ## Confirmable
  # t.string   :confirmation_token
  # t.datetime :confirmed_at
  # t.datetime :confirmation_sent_at
  # t.string   :unconfirmed_email # Only if using reconfirmable

  ## Lockable
  # t.integer  :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
  # t.string   :unlock_token # Only if unlock strategy is :email or :both
  # t.datetime :locked_at

  ## Token authenticatable
  # t.string :authentication_token


  t.timestamps
end

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

end
end

I'm having the same problem...hmm. I put something up on Stackoverflow. When I find out anything, I'll let you know :)

2 Answers

Can you please post that migration file?

I think there is a little confusion here migrations and routes are two separate things.

Migrations change the structure of the database tables. In rails the model's attributes are the table columns - so migrations change the model's attributes. The easiest way to see the changes are in the rails console (at the command line type: rails console). And then doing a new object and seeing the attributes (type: User.new).

The routes, the URL's the application respond to, are changed by updating config/routes.rb and then restarting the rails server. If you now do: rake routes the changes should be seen.

Rich