Checking input data in the form when button clicked

Hi, I’m trying to check the data in the fields in the form and if valid
save in the corresponding tables in the database. But (as I’m new to
rails) just couldn’t figure out how I can do it. Here’s how I’m trying
just to check the input data:

IN CONTROLLER:

class UserController < ApplicationController
def index
end
def update_campsites
@campholder=[]
id=params[“walk_id”]
@camps=Campsite.find_by_sql(“select camp_location from campsites
where walk_id=”+id)
for eachcamp in @camps
@campholder << [eachcamp.camp_location, eachcamp.camp_location]
end
if request.post?
@arrival=params[:arrival_date]
@nights=params[:nights]
@children=params[:children]
print @camp
print @arrival
print @nights
print @children
end
end
end

IN VIEW: (index.rhtml)

Great Walks Online Booking

<%= select(:selected, :id, GreatWalk.getAvailableLocations, {:prompt => 'Select a category'}, :id => :id_selected) %>

<%= observe_field :id_selected, :url => {:action =>
:update_campsites}, :update => :campsites, :with => “walk_id” %>

<%form_tag(:action=>:update_campsites) do %>

Campgrounds <%=select "selected", "camp", Campsite.getAvailableCamps%>

Arrival Date <%=date_select :arrival_date, params[:arrival_date]%>

Nights <%=text_field_tag :nights, params[:nights]%>

Parents <%=text_field_tag :parents, params[:parents]%>

Children <%=text_field_tag :children, params[:children]%>

Total <%=text_field_tag :total, params[:total]%>

<%=submit_tag "Calculate"%> <%end%> --------------------------------------------------------------------------------

IN VIEW: (update_campsites.rhtml)

<%=select “selected”,“camp”,@campholder%>

I’m getting this error:

TypeError in UserController#update_campsites
can’t convert nil into String
RAILS_ROOT: C:/Users/Jay/Aptana/greatwalks

Application Trace | Framework Trace | Full Trace

Request
Parameters:

{“authenticity_token”=>“7ab6ae4172e01c7cb2e7346ee13ce55548da1a7a”,
“selected”=>{“camp”=>“Jabiru Swamp”},
“arrival_date”=>{"(1i)"=>“2008”,
“(2i)”=>“10”,
“(3i)”=>“6”},
“nights”=>“df”,
“parents”=>“klj”,
“children”=>“kj”,
“total”=>“kj”,
“commit”=>“Calculate”}

Show session dump

Response
Headers:

{“Cache-Control”=>“no-cache”,
“cookie”=>[]}