> CONTROLLER:
>
> def add_to_cart
> if params[:children].nil?
> if params[:family_claim]=="1"
> return (redirect_to_booking("You can't claim for family rate
> without children."))
> end
> else
> if ((params[:parents].to_i) + (params[:children].to_i)) > 8
> return (redirect_to_booking("Maximum 8 people in a group."))
> end
> end
> if params[:family_claim] != "1"
> total = (((params[:parents].to_i + params[:children].to_i) * 4.85)
> * params[:nights].to_i)
> else
> total = (19.4 * params[:nights].to_i)
> end
def add_to_cart
@cart=find_cart
carts=Cart.create(:campsite => params[:camp][:id],
:arrival_date => params[:arrival_date],
:nights => params[:nights],
:parents => params[:parents],
:children => params[:children],
:family_claim => params[:family_claim],
:total => total)
msg = ''
# stick all that logic in the cart model
if carts.validate_input_rules(msg)
if carts.save
@cart << carts.id
@cart_details = find_items_in_session
else
msg = 'Bad input, try again msg'
end
end
unless msg.empty?
redirect_to_booking msg
end
end
Maybe?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---