Hi, I''m trying to display separate menus based on records in database tables. The menus are situated within a form which separates the menus based on their service type. The ''service'' table references the costcenter_id so each service is either in category X or Y. Each menu is supposed to list all of the items in X or Y. Since there are only two records (X and Y) in the ''costcenter'' table, only two menus should show up. The menus show up fine and are populated with the items correctly, but he problem is that the first menu works fine, but the second menu does nothing at all when I submit the form. Whenever I select an item in the second menu, what shows is the same error as if I had selected no data in the form and tried to submit it. I always see this error: " NoMethodError in ConsultsController#create You have a nil object when you didn''t expect it! The error occurred while evaluating nil.charge_rate" Why would the first menu be able to see @var.charge_rate but not the second? ------------------------------------------------------ In the view: ------------------------------------------------------ <div class="content"> <% @costcenters.each_with_index do |costcenter, index| %> <h3> <%= costcenter.name %> <INPUT TYPE="button" VALUE="Click To Show/Hide" onClick="hider(<%index %>)" > </h3> <div style="display: none;" id=<%= index %> > <select name="consult[service_id]"> <option></option> <% @services.each do |service| %> <% if service.active != 0 %> <% if service.costcenter_id == costcenter.id %> <%= service.name %> <option <% if @consult.service_id == service.id %> selected <% end %> value="<%= service.id %>"> <%= service.name %> </option> <% end %> <% end %> <% end %> </select> </div> <% end %> </div> ---------------------------------------------------------- In the controller: ---------------------------------------------------------- def create <snip> #the next 3 lines will get the charge rate serv_id = @consult.service_id @service = Service.find(:first, :conditions => ["id = ?", serv_id]) @consult.charge_rate = @service.charge_rate @consult.total_charge = Consult.totalCharge(@minutes, @consult.charge_rate) if @consult.save flash[:notice] = ''Consult was successfully created.'' redirect_to :action => ''list'' else render :action => ''new'' end end -- 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 -~----------~----~----~----~------~----~------~--~---