On Jan 4, 6:22 pm, Frederick Cheung <[email protected]>
wrote:
> On Jan 4, 4:10 pm, radu puspana <[email protected]> wrote:
>
> > and this line : user.detect {|current_user| current_user ==
> > User.encrypt(password,current_user)}, shouldn't be something like
> > user.detect {|current_user| current_user == User.encrypt
> > (password,current_user.salt)}
>
> that's right.
> This means: iterate over the user collection, passing each element
> into the block as current_user. return the first element for which the
> condition in the block returns true.

Sry for bothering you agan but shouldn't it be :
 user.detect {|current_user| current_user.hashed_password ==
User.encrypt(password,current_user.salt)} reather than user.detect {|
current_user| current_user== User.encrypt
(password,current_user.salt)} ??.
== means a condition if i recall correctly.
because the string that comes out of  User.encrypt
(password,current_user.salt)} should be compared with something in the
current_user, namely hashed_password,  not the object refered by the
variable current_user, right?
>
> > > You'll also find your code reads more easily if variables that contain
> > > collections are pluralised (ie users = User.find :all rather than user
> > > = User.find( :all))
>
> > thx so much for this tip too, it doesn't have to do anything with the
> > line user.detect {|current_user| current_user == User.encrypt
> > (password, current_user)} right?
>
> no. just a stylistic thing
 thx again for the trick:)
> Fred

much much appreciate it Fred,
regards,
radu

--

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 [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.


Reply via email to