I''ve setup a quoting system that does a quick job of displaying a price to a user. I works ok but I need to validate that the user has actually selected a course and a duration, hopefully with a feedback message. At the moment this all works apart from if a user submits a blank form (then I understandably get a nill object error) How do I do this? Here''s the code so far... ============ Initial Form --------- <% form_tag :action => ''price'' do %> <%= collection_select(:course, :id, @courses, :id, :name, options ={:prompt => "-Select a course"}, :class =>"course") %> <%= select(''course'', ''course_duration'', 1..52, { :include_blank => true } ) %> <%= submit_tag "Price" %> <% end %> Controller -------- class InvoiceController < ApplicationController def index @enquiry = Enquiry.new @courses = Course.active_courses @courses = Course.active_courses render :layout => "welcome" end def price @time = Time.now @selected_course = Course.find_by_id(params[:course][:id]) @duration = params[:course][:course_duration] @total_price = @duration.to_i * @selected_course.price_per_week render :layout => "welcome" end end Display the price view ----------------- <%= @time %><br> <hr> Price Below<br> <hr> <br> <strong> Course: <%= @selected_course.name %> </strong> <br> Price per week: <%= number_to_currency(@selected_course.price_per_week, :unit => "£", :separator => ".", :delimiter => ",") %> <br> Duration: <%= @duration %> weeks<br> <br> <h1> Total Price: <%= number_to_currency(@total_price, :unit => "£", :separator => ".", :delimiter => ",") %> <br> </h1> <br> Please note that this price is indicative and not a binding quotation. Terms and conditions apply. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---