While I''m pulling data out of a form I''m trying to do this unless v[:state_id] = 0 # Should be interpreted as the state_id is the number zero. However it doesn''t seem to be working for some reason. The conditional about it is unless v[:state_id].blank? # this conditional works unless v[:state_id] = 0 I''ve tried single quotes, double quotes and nothing seems to be stopping it. Any obvious reasons ? Stuart -- http://en.wikipedia.org/wiki/Dark_ambient --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
hi stuart! Dark Ambient [29.10.2006 22:05]:> While I''m pulling data out of a form I''m trying to do this > > unless v[:state_id] = 0 # Should be interpreted as the state_id > is the number zero.what you''re actually doing here is *assigning* (=) the value 0 to your variable (returning that value, which in ruby is true), while what you''d rather want is *testing* for equality (==). long story short: s/=/==/ will do the trick ;-) cheers jens -- Jens Wille, Dipl.-Bibl. (FH) prometheus - Das verteilte digitale Bildarchiv für Forschung & Lehre An St. Laurentius 4, 50931 Köln Tel.: +49 (0)221 470-6668, E-Mail: jens.wille-31N1O1AsgN5n68oJJulU0Q@public.gmane.org http://www.prometheus-bildarchiv.de/ --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
n 10/29/06, jens wille <jens.wille-31N1O1AsgN5n68oJJulU0Q@public.gmane.org> wrote:> > > hi stuart! > > Dark Ambient [29.10.2006 22:05]: > > While I''m pulling data out of a form I''m trying to do this > > > > unless v[:state_id] = 0 # Should be interpreted as the state_id > > is the number zero. > what you''re actually doing here is *assigning* (=) the value 0 to > your variable (returning that value, which in ruby is true), while > what you''d rather want is *testing* for equality (==).Well I did try == 0 , and basically layed there like a dead mouse. long story short: s/=/==/ will do the trick ;-) what is this ? is this a typo , because this won''t parse . Stuart cheers> jens > > -- > Jens Wille, Dipl.-Bibl. (FH) > prometheus - Das verteilte digitale Bildarchiv für Forschung & Lehre > An St. Laurentius 4, 50931 Köln > Tel.: +49 (0)221 470-6668, E-Mail: jens.wille-31N1O1AsgN5n68oJJulU0Q@public.gmane.org > http://www.prometheus-bildarchiv.de/ > > > >-- http://en.wikipedia.org/wiki/Dark_ambient --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Dark Ambient [29.10.2006 22:19]:>> long story short: s/=/==/ will do the trick ;-) > what is this ? is this a typo , because this won''t parse .well, it just means that you have to substitute the single = by ==. however, you said that your data came out of a form which probably makes them strings, so you might try: v[:state_id] == ''0'' or v[:state_id].to_i == 0 hth jens -- Jens Wille, Dipl.-Bibl. (FH) prometheus - Das verteilte digitale Bildarchiv für Forschung & Lehre An St. Laurentius 4, 50931 Köln Tel.: +49 (0)221 470-6668, E-Mail: jens.wille-31N1O1AsgN5n68oJJulU0Q@public.gmane.org http://www.prometheus-bildarchiv.de/ --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 10/29/06, jens wille <jens.wille-31N1O1AsgN5n68oJJulU0Q@public.gmane.org> wrote:> > > Dark Ambient [29.10.2006 22:19]: > >> long story short: s/=/==/ will do the trick ;-) > > what is this ? is this a typo , because this won''t parse . > well, it just means that you have to substitute the single = by ==. > > however, you said that your data came out of a form which probably > makes them strings, so you might try: > > v[:state_id] == ''0'' > > or > > v[:state_id].to_i == 0 > > hth > jensWell, I give up , cause none of these plus all the one''s I''ve tried don''t seem to make a difference. Stuart --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
unless v[:state_id] == 0 will return true only if v[:state_id] does not equal zero, is that what you are wanting to do? Or do you want it to check if state_id is not set? (unless v[:state_id]) Dark Ambient wrote:> On 10/29/06, jens wille <jens.wille-31N1O1AsgN5n68oJJulU0Q@public.gmane.org> wrote: > > > > > > Dark Ambient [29.10.2006 22:19]: > > >> long story short: s/=/==/ will do the trick ;-) > > > what is this ? is this a typo , because this won''t parse . > > well, it just means that you have to substitute the single = by ==. > > > > however, you said that your data came out of a form which probably > > makes them strings, so you might try: > > > > v[:state_id] == ''0'' > > > > or > > > > v[:state_id].to_i == 0 > > > > hth > > jens > > > Well, I give up , cause none of these plus all the one''s I''ve tried don''t > seem to make a difference. > > Stuart > > ------=_Part_61105_2467180.1162161164197 > Content-Type: text/html; charset=ISO-8859-1 > X-Google-AttachSize: 927 > > On 10/29/06, <b class="gmail_sendername">jens wille</b> <<a href="mailto:jens.wille-31N1O1AsgN5n68oJJulU0Q@public.gmane.org">jens.wille-31N1O1AsgN5n68oJJulU0Q@public.gmane.org</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> > <br>Dark Ambient [29.10.2006 22:19]:<br>>> long story short: s/=/==/ will do the trick ;-)<br>> what is this ? is this a typo , because this won''t parse .<br>well, it just means that you have to substitute the single = by ==. > <br><br>however, you said that your data came out of a form which probably<br>makes them strings, so you might try:<br><br> v[:state_id] == ''0''<br><br>or<br><br> v[:state_id].to_i == 0<br><br>hth<br>jens</blockquote><div> > <br>Well, I give up , cause none of these plus all the one''s I''ve tried don''t seem to make a difference.<br><br>Stuart <br></div><br></div> > > ------=_Part_61105_2467180.1162161164197----~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 10/29/06, jdswift <jdswift-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > unless v[:state_id] == 0 > will return true only if v[:state_id] does not equal zero, is that what > you are wanting to do? Or do you want it to check if state_id is not > set? (unless v[:state_id])If the state_id IS 0 (meaning the number zero). So I don''t think it should be == , I think it should be = , but I did a != 0 and that really mucked things up. Stuart Dark Ambient wrote:> > On 10/29/06, jens wille <jens.wille-31N1O1AsgN5n68oJJulU0Q@public.gmane.org> wrote: > > > > > > > > > Dark Ambient [29.10.2006 22:19]: > > > >> long story short: s/=/==/ will do the trick ;-) > > > > what is this ? is this a typo , because this won''t parse . > > > well, it just means that you have to substitute the single = by ==. > > > > > > however, you said that your data came out of a form which probably > > > makes them strings, so you might try: > > > > > > v[:state_id] == ''0'' > > > > > > or > > > > > > v[:state_id].to_i == 0 > > > > > > hth > > > jens > > > > > > Well, I give up , cause none of these plus all the one''s I''ve tried > don''t > > seem to make a difference. > > > > Stuart > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Exactly what are you trying to do? do something ''unless v[:state_id] is zero'' do something ''unless "setting v[:state_id] to zero evalutates to true"'' do something ''unless v[:state_id] is not zero'' On Oct 30, 5:56 am, "Dark Ambient" <sambi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 10/29/06, jdswift <jdsw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > unless v[:state_id] == 0 > > will return true only if v[:state_id] does not equal zero, is that what > > you are wanting to do? Or do you want it to check if state_id is not > > set? (unless v[:state_id])If the state_id IS 0 (meaning the number zero). So I don''t think it should > be == , > I think it should be = , but I did a != 0 and that really mucked things up. > > Stuart > > Dark Ambient wrote: > > > On 10/29/06, jens wille <jens.wi...-31N1O1AsgN5n68oJJulU0Q@public.gmane.org> wrote: > > > > > Dark Ambient [29.10.2006 22:19]: > > > > >> long story short: s/=/==/ will do the trick ;-) > > > > > what is this ? is this a typo , because this won''t parse . > > > > well, it just means that you have to substitute the single = by ==. > > > > > however, you said that your data came out of a form which probably > > > > makes them strings, so you might try: > > > > > v[:state_id] == ''0'' > > > > > or > > > > > v[:state_id].to_i == 0 > > > > > hth > > > > jens > > > > Well, I give up , cause none of these plus all the one''s I''ve tried > > don''t > > > seem to make a difference. > > > > Stuart--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 10/30/06, Mike <mike-8LPBsGar6lUAvxtiuMwx3w@public.gmane.org> wrote:> > > Exactly what are you trying to do? > > do something ''unless v[:state_id] is zero'' <-------------- Yes this one.Stuart do something ''unless "setting v[:state_id] to zero evalutates to true"''> do something ''unless v[:state_id] is not zero'' > > On Oct 30, 5:56 am, "Dark Ambient" <sambi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On 10/29/06, jdswift <jdsw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > unless v[:state_id] == 0 > > > will return true only if v[:state_id] does not equal zero, is that > what > > > you are wanting to do? Or do you want it to check if state_id is not > > > set? (unless v[:state_id])If the state_id IS 0 (meaning the number > zero). So I don''t think it should > > be == , > > I think it should be = , but I did a != 0 and that really mucked things > up. > > > > Stuart > > > > Dark Ambient wrote: > > > > On 10/29/06, jens wille <jens.wi...-31N1O1AsgN5n68oJJulU0Q@public.gmane.org> wrote: > > > > > > > Dark Ambient [29.10.2006 22:19]: > > > > > >> long story short: s/=/==/ will do the trick ;-) > > > > > > what is this ? is this a typo , because this won''t parse . > > > > > well, it just means that you have to substitute the single = by > ==. > > > > > > > however, you said that your data came out of a form which probably > > > > > makes them strings, so you might try: > > > > > > > v[:state_id] == ''0'' > > > > > > > or > > > > > > > v[:state_id].to_i == 0 > > > > > > > hth > > > > > jens > > > > > > Well, I give up , cause none of these plus all the one''s I''ve tried > > > don''t > > > > seem to make a difference. > > > > > > Stuart > > > > >-- http://en.wikipedia.org/wiki/Dark_ambient --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Dark Ambient wrote:> On 10/30/06, Mike <mike-8LPBsGar6lUAvxtiuMwx3w@public.gmane.org> wrote: > > Exactly what are you trying to do? > > do something ''unless v[:state_id] is zero'' <-------------- Yes this one.do_something unless v[:state_id] == 0 or unless v[:state_id] == 0 do_something end I suspect that your values are not what you think they are, or that you are having trouble properly testing what is going on. If you are testing for equality, you definitely, absolutely, always want a double equals sign. That you were confused about that makes me think that your life might become easier if you read a beginner''s book on programming in Ruby. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 10/30/06, Phrogz <gavin-XtLdkLkwz3ZWk0Htik3J/w@public.gmane.org> wrote:> > > Dark Ambient wrote: > > On 10/30/06, Mike <mike-8LPBsGar6lUAvxtiuMwx3w@public.gmane.org> wrote: > > > Exactly what are you trying to do? > > > do something ''unless v[:state_id] is zero'' <-------------- Yes this > one. > > do_something unless v[:state_id] == 0 > > or > > unless v[:state_id] == 0 > do_something > end > > > I suspect that your values are not what you think they are, or that you > are having trouble properly testing what is going on. If you are > testing for equality, you definitely, absolutely, always want a double > equals sign. That you were confused about that makes me think that your > life might become easier if you read a beginner''s book on programming > in Ruby.I''m not sure what is meant by equality but if I remember correctly from reading a beginner''s book, equality is not the same as comparing one value to the next. All I am trying to ask (Ruby) is the value in v[:state_id] zero. In that case I believe one set of equal signs is correct. Let me know if I''m wrong or if there is some misunderstanding here. Stuart --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---