0

The attribute, balanced_card_uri, is saving as blank and not showing on this raise:

https://img.skitch.com/20120916-fpmxabwg6m4ys3y84rkti615iq.jpg

Here's the code from customer.rb: https://gist.github.com/ee0b27bebe14d88417d9

After first having problems, I realized I misnamed the attributes in attr_accessble and attr_accessor. I renamed them correctly and the balanced_card_uri still shows blank...

Help!

tbrooks
  • 85
  • 1
  • 9

1 Answers1

1

You raise an error all the time in balanced_customer. Why don't you add some conditionnal statements?

Example:

raise "Balanced Card: #{balanced_card_uri} Email: #{email}" if balanced_card_uri.blank? && email.blank?

Anyway, it's not the way to proceed, you should use validations. Example:

validates :balanced_card_uri, presence: true

Check this page for additional info.


Sidenote: why didn't you add recurring_amount and recurring to your attr_accessible ?


Side-sidenote:

Replace:

before_save :handle_recurring_donations, :if => :recurring

With:

before_save :handle_recurring_donations, :if => :recurring?

The problem seems to stem from your find_or_initialize_by_repeat_donator: you don't take any param into account there.

You should have a line like:

 customer.load(attrs)

With all the params you want to keep.

apneadiving
  • 114,565
  • 26
  • 219
  • 213