views:

24

answers:

2

I have a scenario where I have a model that I want to populate and validate against, but don't necessarily want to write down to the database when it's parent object is.

For instance, let's say I have an account and a credit card model, the credit card is built against the account, and validated when the account is, but also saved when Account.save! is called.

How can I prevent this model from saving down (because I might not want CC data in my database)

+2  A: 

Why don't you write your own save! method to replace its base class?

baloo
Tried this, but this returns:wrong number of arguments (1 for 0)
Neil Middleton
Did you try adding the same number of arguments as the original method?
baloo
ah,def save(options) falseendworks.
Neil Middleton
A: 

Use the #readonly! method:

François Beausoleil