Ar Chron wrote:
> 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?

thanks for the reply Ar Chron!! but what will the implementation of the 
'validate_input_rules()' in model be like coz the code i presented in my 
first post don't seem to do what it is meant for as even though the 
children field is empty and user select the family rate claim check box 
it gets validated ok and the details get saved which actually shouldn't 
happen. so, how can i improve tat code to eliminate this bug? thanks..
-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to