Rails Tutorial 3 attribue unknown

I to the part of the tutorial where a User model is created. It has
the following attributes:

id :integer(4) not null, primary key

name :string(255)

email :string(255)

created_at :datetime not null

updated_at :datetime not null

password_digest :string(255)

Then in an rspec test file the author issues this command:
before do
@user = User.new(name: “Example User”, email: “[email protected]”,
password: “foobar”, password_confirmation:
“foobar”)
end

Now he says that password and password_confirmation are created
temporarily in memory and don’t need to go into the database. But
when I try to run this rspec test it gives me an error stating unknown
attribute: password.

Can anyone help me get around this?
thanx,
mike

I simply add in model:
attr_accessible … :password, :password_confirmation, …

it work
but it can not absolutely truly

Be aware that, it is not safe to set passwords changeable via
mass-assignment.

Rodrigo V. wrote in post #1059872:

Be aware that, it is not safe to set passwords changeable via
mass-assignment.

Your decision, please? How it to solve?

This example doesn’t work without ‘attr_accessable: … , :password,
:password_confirmation …’
and with
‘has_secure_password’

How to set the record field comming from form field?

Have you tried using Rails builtin confirmation
mechanismhttp://guides.rubyonrails.org/active_record_validations_callbacks.html#confirmation
?

On Tue, May 8, 2012 at 5:08 PM, Sergey E. [email protected]
wrote:

You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

  • Aziz M. Bookwala

Website http://azizmb.in/ | Twitter https://twitter.com/azizbookwala
|
Github http://github.com/azizmb

vishal singh wrote in post #1060022:

In users table their is wrong field name i.e password_digest,it should
be
only password not password_digest

Unless someone mentioned ‘password_digest’? Only ‘password’ and
‘password_confirmation’.

In users table their is wrong field name i.e password_digest,it should
be
only password not password_digest