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
do different stuff

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

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

what am I doing wrong?


got it

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