how do i add a record from the console

20 views
Skip to first unread message

fugee ohu

unread,
Dec 6, 2015, 5:04:23 PM12/6/15
to Ruby on Rails: Talk
I've been trying to do it from memory something like this, but it's not working it keeps returning rollback and false

a=Admin.create
a=Admin.find(1)
a.email="us...@host.com"
a.password="password"
a.save

Walter Lee Davis

unread,
Dec 6, 2015, 10:15:47 PM12/6/15
to rubyonra...@googlegroups.com
If you are using Devise or anything like it, you may need to also have password_confirmation = "password" in order to get past that requirement.

Walter
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0421524d-0572-4c09-b9e8-8cca035d07f5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Colin Law

unread,
Dec 7, 2015, 3:59:10 AM12/7/15
to Ruby on Rails: Talk
It is getting rather tedious repeatedly pointing you to where in
railstutorial.org you can find the solution to the questions you ask.
In this case the answer is in section 6.1.3 Creating user objects.

I can only suggest once again that you take a couple of days out and
work right through that tutorial, including doing all the exercises.
Then you would not need to waste your time asking such questions.

Colin
Reply all
Reply to author
Forward
0 new messages