Note that there are some explanatory texts on larger screens.

plurals
  1. POvalidations for certain actions in model
    text
    copied!<p>I am encountering a problem which I have never encountered before. I am working on code that was written by another programmer and it is kind of a mess.</p> <p>Here is the problem. I have the following validations in the my model :</p> <pre><code>validates_presence_of :subscription_level, :message =&gt; 'please make a selection' validates_presence_of :shipping_first_name validates_presence_of :shipping_last_name validates_presence_of :shipping_address validates_presence_of :shipping_city validates_presence_of :shipping_state validates_presence_of :shipping_postal_code validates_presence_of :shipping_country validates_presence_of :billing_first_name validates_presence_of :billing_last_name validates_presence_of :billing_address validates_presence_of :billing_city validates_presence_of :billing_state validates_presence_of :billing_postal_code validates_presence_of :billing_country validates_presence_of :card_number validates_numericality_of :card_number validates_presence_of :card_expiration_month validates_numericality_of :card_expiration_month validates_presence_of :card_expiration_year validates_numericality_of :card_expiration_year validates_presence_of :card_cvv validates_numericality_of :card_cvv </code></pre> <p>I have two actions for the controller in question. One is <code>new</code> and the other is <code>redeem</code>. I want to perform all of these validations with the <code>new</code> action but want to skip most of them for <code>redeem</code> action.</p> <p>The problem I am facing right now is that using <code>valid?</code> in the controller is also validating things which are not required for <code>redeem</code> action.</p> <p>How can I get around this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload