Hi, I'm trying to validate couple of things in the controller as I
couldn't figure out how I can implement the same in the models. I'm
trying to check the 'children' field in the form and if its nil, it
checks the 'family claim' check box and if its ticked show error message
and if this is validated ok then checks that the sum of children and
parents field's values don't exceed 8. If everything's fine then do the
saving in the carts table. Here's how I've implemented it but doesn't do
the job for the combination of children and family claim field:
return (redirect_to_booking("You can't claim for family rate
if ((params[:parents].to_i) + (params[:children].to_i)) > 8
return (redirect_to_booking("Maximum 8 people in a group."))
if params[:family_claim] != "1"
total = (((params[:parents].to_i + params[:children].to_i) * 4.85)
total = (19.4 * params[:nights].to_i)
carts=Cart.create(:campsite => params[:camp][:id], :arrival_date =>
:nights => params[:nights], :parents =>
:children => params[:children], :family_claim =>
:total => total)
@cart << carts.id
@cart_details = find_items_in_session
redirect_to_booking("Invalid input. Details couldn't be stored.
Please Try Again..")
Any suggestions.. thanks..