Je suis en train de créer une application de démonstration avec l'authentification devise dans rails.
Je suis confronté à cette erreur
rake aborted!
Can't mass-assign protected attributes: confirmed_at
ma classe User.rb est
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :name, :email, :password, :password_confirmation, :remember_me
# attr_accessible :title, :body
validates_presence_of :name
validates_uniqueness_of :name, :email, :case_sensitive => false
end
et le code de mon fichier db.seed.rb est le suivant
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
puts 'SETTING UP DEFAULT USER LOGIN'
user = User.create! :name => 'First User', :email => 'user@example.com', :password => 'please', :password_confirmation => 'please', :confirmed_at => DateTime.now
user2 = User.create! :name => 'Second User', :email => 'user2@example.com', :password => 'please', :password_confirmation => 'please', :confirmed_at => DateTime.now
puts 'New user created: ' << user.name
user.rb est une classe modèle. Lorsque j'exécute la commande $ bundle exec rake db:seed
Je suis confronté à cette erreur rake aborted ! Impossible d'attribuer en masse les attributs protégés : confirmed_at