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 Build a Simple Ruby on Rails Application Creating an Authentication System Pulling the Latest Code

Fields are not getting pushed into database.

I've watched these videos a few times now, and I still haven't figured out how to get the "first name, last name, and profile name" injected into the database. All my files are setup exactly like the videos.. frustrating... any ideas?

5 Answers

Tommy Gebru
Tommy Gebru
30,164 Points

Can you post your code to share?

Tommy Gebru
Tommy Gebru
30,164 Points

Can you post your code to share?

Sure.. here's the migration file where it should be making it all work.. I think? :

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, null: false
  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, null: false # Only if lock strategy is :failed_attempts
  # t.string   :unlock_token # Only if unlock strategy is :email or :both
  # t.datetime :locked_at


  t.timestamps
end

add_index :users, :email,                unique: true
add_index :users, :reset_password_token, unique: true
# add_index :users, :confirmation_token,   unique: true
# add_index :users, :unlock_token,         unique: true

end end

Tommy Gebru
Tommy Gebru
30,164 Points

I think your post has code above the code window can you fix that?

I figured it out.. In Rails 4 you have to add parameters in the application controller.. Here's what the code looks like:

class ApplicationController < ActionController::Base
  before_action :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) << :first_name
    devise_parameter_sanitizer.for(:sign_up) << :last_name
    devise_parameter_sanitizer.for(:sign_up) << :profile_name
  end
end