Rails Tutorial 3 attribue unknown

11 views
Skip to first unread message

mike

unread,
May 4, 2012, 8:20:24 PM5/4/12
to Ruby on Rails: Talk
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: "us...@example.com",
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

Sergey Ezhov

unread,
May 6, 2012, 4:10:12 AM5/6/12
to rubyonra...@googlegroups.com
I simply add in model:
attr_accessible ... :password, :password_confirmation, ...

it work
but it can not absolutely truly

--
Posted via http://www.ruby-forum.com/.

Rodrigo Vieira

unread,
May 6, 2012, 6:49:03 PM5/6/12
to rubyonra...@googlegroups.com
Be aware that, it is not safe to set passwords changeable via mass-assignment.
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>

Sergey Ezhov

unread,
May 8, 2012, 7:38:30 AM5/8/12
to rubyonra...@googlegroups.com
Rodrigo Vieira 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?

azizmb.in

unread,
May 8, 2012, 7:46:07 AM5/8/12
to rubyonra...@googlegroups.com
Have you tried using Rails builtin confirmation mechanism?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.




--
- Aziz M. Bookwala

Sergey Ezhov

unread,
May 8, 2012, 9:46:56 AM5/8/12
to rubyonra...@googlegroups.com
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?

vishal singh

unread,
May 8, 2012, 10:41:04 AM5/8/12
to rubyonra...@googlegroups.com
In users table their is wrong field name i.e password_digest,it should be only password not password_digest

Sergey Ezhov

unread,
May 11, 2012, 4:35:01 AM5/11/12
to rubyonra...@googlegroups.com
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

Someone mentioned 'password_digest'? Only 'password' and
'password_confirmation'.
Reply all
Reply to author
Forward
0 new messages