Hi, I have a form that submits values from text fields and a check box.
The values posted are: camp location name, number of nights, number of
parents, number of children, value from the check box "family claim".
Where camp name can't be nil, nights can't be more than 2, parents and
children together can't be more than 8 and if there are no children
specified check box can't be checked. Here's my unsuccessful
implementation for this:

def add_to_cart
 begin
   cart=find_cart
   camp_loc = params[:camp][:id]
   nights=params[:nights]
   parents=params[:parents]
   children=params[:children]
   family_rate_claim=params[:family_claim]
 rescue
   redirect_to_booking("Invalid input.")
 end
 if camp_loc.blank? || nights.blank? || parents.blank?
    redirect_to_booking("Fields with '*' are required fields.")
 elsif (nights.to_i > 2) || ((parents.to_i + children.to_i) > 8)
    redirect_to_booking("Limitation: Maximum stay of 2 nights with group
of maximum 8 people.")
 elsif children.nil? and family_rate_claim == "1"
    redirect_to_booking("You are not eligible for claiming family
rate.")
 else
    ....add the stuff in the cart
 end
end

def redirect_to_booking(msg)
 flash[:notice]=msg
 render :action => :online_booking
end

When I click the button without giving anything as the input I get this:

Render and/or redirect were called multiple times in this action. Please
note that you may only call render OR redirect, and at most once per
action. Also note that neither redirect nor render terminate execution
of the action, so if you want to exit an action after redirecting, you
need to do something like "redirect_to(...) and return".

but what I want is to to get redirected to the same page with error
information.
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