Observe_field with select

Hi,

I’ve been struggling to understand observe_field for quite some time,
and I figured I’d try posting here for help.

My goal is the following:

  1. Create a select box for users to select a school
  2. Show database info about selected school without a page refresh

I’ve consulted many sources; Here is the one I modeled this attempt
after:
http://www.roryhansen.ca/2005/06/21/related-drop-down-lists-with-ruby-and-ajax/

This is what I have so far:

// app/views/school/index.rhtml

<%= javascript_include_tag :defaults %>

Schools:

Select School <% @schools.each do |school| %> <%= school.name %> <% end %>

<%= observe_field(“school[school_id]”,
:frequency => 0.25,
:update => “school_editor”,
:url => {:action => :update_school_editor},
:with => “'school_id=‘value’”) %>

// app/controllers/school_controller.rb

class SchoolController < ApplicationController

def index
@schools = School.find(:all, :order => ‘name’)
end

def update_school_editor
@school = @schools.find_by_id(params[“school_id”])
@html = “ID: #{@school.id}
Name: #{@school.name}”
end
end

Thanks