Form removing leading zeros for a string

Hi,

I have a drop down select see below which populates from the below,

select(:record, :visually_similar_to, Sample.find(:all).collect {|p|
p.sample_ref, p.id ] })

sample_ref is varchar field so the values that populate the drop down
are below and they include the leading zeros

0003
0004
0005
etc…

When i save this record the field is called visually_similar_to this
removes the leading zeros and leaves it with just the 3 or 4 etc

Why is it removing the leading zeros if its saving to a string field,
how can i stop this. I dont always know how many characters will be in
the field so i couldnt just count the number of characters and then add
the missing zero’s, this shouldnt be neccessary anyway because its a
string field?

Can anyone help?

JB

Sorry for the stupid question, its saving the id and not the sample_ref
field, doh! I need a day off!

JB

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