Note that there are some explanatory texts on larger screens.

plurals
  1. POerrors(:base) << message leads undefined method `map' for nil:NilClass
    primarykey
    data
    text
    <p>I am trying to integrate ActiveMerchant into my website using Rails 3.2. Currently I have code to do general validation on a credit card using the ActiveMerchant "valid" function, which returns some error message if the card i not valid. If there are errors then I would like to add them to errors and re-render the view to display the view with the errors. Below is the code in my controller.</p> <p><strong>First I create a credit card</strong></p> <pre><code>def credit_card first_name = User.find(user_id).first_name last_name = User.find(user_id).last_name @credit_card ||= ActiveMerchant::Billing::CreditCard.new( :brand =&gt; card_type, :number =&gt; card_number, :verification_value =&gt; card_verification, :month =&gt; card_expiration.month, :year =&gt; card_expiration.year, :first_name =&gt; first_name, :last_name =&gt; last_name ) end </code></pre> <p><strong>Next I validate the card and try to add errors returned to the base errors for views</strong></p> <pre><code># Active Merchant Credit Card validation def validate_card unless credit_card.valid? credit_card.errors.full_messages.each do |message| errors[:base] &lt;&lt; message end end end </code></pre> <p><strong>Finally I call valid_card on the create</strong></p> <pre><code>validate :validate_card, :on =&gt; :create </code></pre> <p><strong>However I am getting the error below</strong></p> <blockquote> <p>NoMethodError in Orders#create</p> <p>Showing app/views/orders/_form.html.erb where line #18 raised:</p> <p>undefined method `map' for nil:NilClass Extracted source (around line</p> <h1>18):</h1> <p>15: 16: 17: &lt;%= f.label :print_dimension %><br /> 18: &lt;%= f.collection_select :print_dimension_id, @print_dimensions, :id, :dimension %> 19: 20: 21: &lt;%= f.label :delivery_option_id %><br /></p> </blockquote> <p>Please let me know if you have any suggestions. Thank you</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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