The salt of password can't save to MySQL

Hi,

I am solving already 3 hours this weird problem:

class Func
def self.md5(string)
Digest::MD5.hexdigest(string)
end

def self.salt(length=10)
chars = ‘abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789’
salt = ‘’
length.times { salt << chars[rand(chars.size)] }
salt
end
end

In controller:
password = Func.md5(params[:registrace][:heslo])
passsalt = Func.salt(10)

puts password //here is it ok
puts passsalt //here is it ok
@saveit = Table.new(:pass_salt => passsalt, // problem -- to dabase

is stored NULL
:passw => password + passsalt)
//but here is is ok, passalt contains right string

The column in database ‘Table’ for salt called ‘pass_salt’. This column
have type ‘varchar(10)’. The lenght of salt is 10 chars.
I don’t know where could be fault, but into the column ‘passw’ is
everything stored great, but to the column ‘pass_salt’ the string
contains salt does not stored…

I will glad for any help, I have no idea, where could be a problem…
Thanks a lot,
Manny

Problem solved – after 3 hours long sleep I saw it – attr_accessible.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs