I am trying to conditionalize validation of fields being sent in a view by passing a variable from the view to the model so it knows which set of fields to check.
The model looks like this:
validates_presence_of :first_name, :last_name, :if => :registration_step?
validates_numericality_of :primary_phone, :if => :contact_step?
def registration_step?
@step == :register
end
def contact_step?
@step == :contact
end
I'm not sure what I have to place in my view in order for everything to function properly. I've tried
<% @step = :register %>
and
<% @step = :contact %>
As well as some other combinations (:step, and also @step with 'register' and 'contact'. I know it's just a matter of syntax or I'm just missing one more thing in the model but I can't figure it out.`