Jeff Miller wrote:
sweet, thanks guys! I have another question, though... If all of this is
being done in the view, then if I have to make changes to some of the
variables, I have to that in the view too, right? I used this line to
change the string length in the view:
<%= bes.bes_phonenumber if bes.bes_phonenumber.size==11
It is supposed to cut off the first digit of the phone number if the
length of the number is 11 characters long. However, this doesn't work
(compile error). Can somebody clarify this for me?
I appreciate everyone's help, thank you!
- Jeff Miller
you mean you want to say: if the phonenumber's size is 11 cut the first
digit from it right?
<%if bes.bes_phonenumber.to_s.size == 11%>
<%bes.bes_phonenumber = bes.bes_phonenumber.to_s.slice(1..11)%>
so here in line 1 you get the string size of bes_phonenumber then in
line 2take off the leading digit and store the result in
bes_phonenumber...but then bes_phonenumber is a string so the last line
converts it back to an int
this is without doubt NOT the best way of doing this (in fact it's
probably the worst), but it works....