Simple if then question?

I need to do a if field value = 1 then method but I cannot seem to
find the right way /sytax for it.

I have a rule table which contains a selector_id field. If set to 1
then do A else do B.

No matter what type of syntax I try I cannot seem to get it working.
Anyone that can help out?

NeoWip wrote:

if (field_value == 1)
do stuff
else
do different stuff
end

Make sure you use a double = when comparing values.

I still get a NameError in RulesController#learnif

The table name is rules, model name rule and the field is
selector_id.

Here is what I have
if (selector_id == 1)
@rules = ‘test’
else
@rules = ‘works’

what am I doing wrong?

got it

t = Rule.find(1)
if ( t.selector_id == 2)
  @rules = 'test'
else
  @rules = 'works'

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