I built an input form that's spread over multiple pages. I store the
already given data (that match my models and my tables) in a cart-like
object. That works so far. But since I dont save the data, when the
user inputs it, validations don't work. They may work on my last
(submit) page, but that too late.
Any way to make validations work even if they don't pass the model?
thx for your hint. So far, I was able to add basic validation to my
model like that
def validate
errors.add_on_empty %w{ title description }
end
And in my controller where I temporarily store that object in my
virtual cart I can probe on validity like that :
def create
@product = Product.new(params[:product])
if @product.valid?
if @cart = find_cart
@cart.add_product(@product)
redirect_to(:action => 'display_cart')
else
render :action => 'new'
end
else
redirect_to(:action => 'new')
end
end
But that great validation features for forms are still closed for me at
that point. Anything I dont see? This way, I'd to to all that by hand
.... and I'm a lazy typist