I hope someone can help, this is driving me mad.
I'm adding different postage methods to my cart which are user selectable.
A cart can have only one postage method, and a postage method can have
many rates. So, I have this:
class Cart < ActiveRecord::Base
class PostageMethod < ActiveRecord::Base
has_many :rates, :class_name => 'PostageRate'
class PostageRate < ActiveRecord::Base
What I'm doing is updating the cart postage cost attribute every time
the the cart is updated (add item, remove item, etc). This is based on
the total weight in the cart. I have data like this for each postage
lower upper price
0 100 1.25
101 200 1.50
201 300 1.75
So, my questions.
1. Should I dump the database table and put this in a non ActiveRecord class?
I don't know if I'm over complicating this when I know there will
probably only ever be two postage methods.
2. If the user chooses the method which has a limit, and the cart is
over that limit, I was going to automatically change the users postage
method and recalculate their postage using the new postage method. I
need to show the user a message explaining this. The problem is, how
to I propagate that message up through two different objects to the
controller? Do I throw a PostageChanged exception and then catch it in
my controller? The problem with doing that is that my database update
is then rolled back because I am throwing an exception within an
Is there a way to get active record to not rollback on an exception thrown?
How would you handle this sort of problem?
Any advice would be appreciated.