RoR Listbox help


#1

Totally new to RoR, have done Riding on Rails Revisited and the
Getting started with Rails Tutorial. Plus I have read why’s poignant
guide on ruby (very helpful guide btw, helped me understand a lot.
After doing the cookbook2 tutorial, I’m redoing it attempting to
modify it to my needs. I made a home controller (from the getting
started with ruby on rails guide) and deleted my index from public. I
setup my routes correctly and the new home page comes up fine. I have
a few tables in my MYSQL created and populated and my ROR app talking
to them. One of the tables with sample data has 20k + records, so I
want to make a list box my home page that filters it. Had trouble
finding list boxes in the API but some google searching gave me some
good info (http://shiningthrough.co.uk/blog/show/6).

Following that mini tutorial and the API docs on collection_select I
tried creating a select box, whos option values are populated by my
database, on my index.html.erb page. I am missing something really
obvious as the page now generates an no methoddefined error on my
collection_select line.

<%= collection_select( :geog, :areaname, @geogs, :area, :areaname,
{:prompt => true}) %>

Heres my geogs_controller.rb that was created using scaffolding.

class GeogsController < ApplicationController

GET /geogs

GET /geogs.xml

def index
@geogs = Geog.find(:all)

respond_to do |format|
  format.html # index.html.erb
  format.xml  { render :xml => @geogs }
end

end

GET /geogs/1

GET /geogs/1.xml

def show
@geog = Geog.find(params[:id])

respond_to do |format|
  format.html # show.html.erb
  format.xml  { render :xml => @geog }
end

end

GET /geogs/new

GET /geogs/new.xml

def new
@geog = Geog.new

respond_to do |format|
  format.html # new.html.erb
  format.xml  { render :xml => @geog }
end

end

GET /geogs/1/edit

def edit
@geog = Geog.find(params[:id])
end

POST /geogs

POST /geogs.xml

def create
@geog = Geog.new(params[:geog])

respond_to do |format|
  if @geog.save
    flash[:notice] = 'Geog was successfully created.'
    format.html { redirect_to(@geog) }
    format.xml  { render :xml => @geog, :status

=> :created, :location => @geog }
else
format.html { render :action => “new” }
format.xml { render :xml => @geog.errors, :status
=> :unprocessable_entity }
end
end
end

PUT /geogs/1

PUT /geogs/1.xml

def update
@geog = Geog.find(params[:id])

respond_to do |format|
  if @geog.update_attributes(params[:geog])
    flash[:notice] = 'Geog was successfully updated.'
    format.html { redirect_to(@geog) }
    format.xml  { head :ok }
  else
    format.html { render :action => "edit" }
    format.xml  { render :xml => @geog.errors, :status

=> :unprocessable_entity }
end
end
end

DELETE /geogs/1

DELETE /geogs/1.xml

def destroy
@geog = Geog.find(params[:id])
@geog.destroy

respond_to do |format|
  format.html { redirect_to(geogs_url) }
  format.xml  { head :ok }
end

end
end