Ruby on Rails Tuesday, January 4, 2011

First I copied what I did from the rails console.The you can the file I
attached.

Loading development environment (Rails 3.0.3)
irb(main):001:0> me = User.new
=> #<User id: nil, faculty_id: nil, department_id: nil, role_id: nil,
name: "", surname: "", username: "", study_group: nil, study_cour
se: nil, card_code: nil, day_time: false, email: nil, hashed_password:
nil, salt: nil>
irb(main):002:0> me.name = 'Daniel'
=> "Daniel"
irb(main):003:0> me.surname = 'Garcia'
=> "Garcia"
irb(main):004:0> me.username = 'vinagrito'
=> "vinagrito"
irb(main):005:0> me.role_id = 1
=> 1
irb(main):006:0> me.save
=> false
irb(main):007:0> me.errors
=> {:password=>["is too short (minimum is 8 characters)"], :email=>["is
invalid", "can't be blank"]}
irb(main):008:0> me.password = '12345678'
=> "12345678"
irb(main):009:0> me.email = 'mail@mail.com'
=> "mail@mail.com"
irb(main):010:0> me.save
=> true
irb(main):011:0> me
=> #<User id: 2, faculty_id: nil, department_id: nil, role_id: 1, name:
"Daniel", surname: "Garcia", username: "vinagrito", study_group
: nil, study_course: nil, card_code: nil, day_time: false, email:
"mail@mail.com", hashed_password: "6305ee7016b263c0ec41a81439a378837a
318035", salt: "5c33e8fed10b87c9f4b7841f0faeb7b10424289a">
irb(main):012:0> user = User.where(:id => 1)
=> []
irb(main):013:0> user = User.where(:id => 2)
=> [#<User id: 2, faculty_id: nil, department_id: nil, role_id: 1, name:
"Daniel", surname: "Garcia", username: "vinagrito", study_grou
p: nil, study_course: nil, card_code: nil, day_time: false, email:
"mail@mail.com", hashed_password: 6305.0, salt: "5c33e8fed10b87c9f4b
7841f0faeb7b10424289a">]
irb(main):014:0> user.to_sql
=> "SELECT `users`.* FROM `users` WHERE (`users`.`id` = 2)"
irb(main):015:0>

And in my DB everything's OK.But of course,as soon as I make a query
from my controller then is going to bring "trash" (check at the
hashed_password column in the rails console after I query for the
record!)

Attachments:
http://www.ruby-forum.com/attachment/5654/mysql_cmd_line.JPG


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

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment