Neeraj Kumar
2006-Jan-14 21:26 UTC
[Rails] if condition on validates_presence_of is not working
class Event < ActiveRecord::Base attr_accessor :step_processing validates_presence_of :name,:description , :if => (:step_processing =4) end class TestController < ApplicationController def bar @event = Event.new @event.step_processing = 4 @event.name = ''foo'' @event.save end end In the above code :step_processing a non-database field. It''s just there to 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. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060114/92acf8de/attachment.html