Ruby on Rails Friday, July 27, 2012

I'm using

before_save :encrypt_password

def encrypt_password
unless password.blank?
self.password_digest = BCrypt::Password.create(password)
self.password = nil
self.password_confirmation = nil
end
end

tom

On Jul 27, 2012, at 12:30 , Michael Pavling <pavling@gmail.com> wrote:

> On 27 July 2012 11:13, sumit srivastava <sumit.theinvincible@gmail.com> wrote:
>> During customizations I have used password as the column where encrypted
>> password shall be saved. So I created my own attr_accessor, i.e.,
>> passwordtext. I have named the password_field_tag in my form as
>> passwordtext. But when I do so, it is not executed. Instead if I rename the
>> password_field_tag and the attr_accessor as password only, it is executed
>> but the stackerror comes in.
>
> All of this info would have been very helpful in your OP.... anyway...
>
> ... what happens when you try this:
>
> def passwordtext=(pass)
> @passwordtext=pass
> self.salt = User.random_string(10) if !self.salt?
> self.password = User.encrypt(@passwordtext, self.salt)
> end
>
> If it's still overflowing, can you post the error message again (since
> the model has changed since your first post this morning) and the
> corresponding method from the controller, as it might be something in
> there behaving weirdly.
>
> --
> 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 https://groups.google.com/groups/opt_out.
>

--
===============================================================================
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz
===============================================================================

--
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 https://groups.google.com/groups/opt_out.

No comments:

Post a Comment