Forum: Ruby on Rails if condition on validates_presence_of is not working

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
B72610c28afc18f4b817770c8b9accd8?d=identicon&s=25 Neeraj Kumar (Guest)
on 2006-01-14 22:34
(Received via mailing list)
class Event < ActiveRecord::Base
  attr_accessor :step_processing

  validates_presence_of :name,:description , :if =>  (:step_processing

class TestController < ApplicationController

def bar
  @event =
  @event.step_processing = 4 = 'foo'


In the above code :step_processing a non-database field. It's just there
control the processing. The validation should take place only when the
step_processing is '4' but in reality it's done every single time. I
guess I
am goofing up the syntax or something like that.

This topic is locked and can not be replied to.