Have been searching for a solution to this problem for a few weeks and
have had no luck.  I''m sure its a newbie mistake, but can''t
figure out
how to solve it.
My problem is that I have several dependent select lists that need to be
populated from a database.  The selected items then need to be saved
back to the database. This is a medical application and basically, the
user selects a cancer site in the top level select list which then
generates a list of site-specific tumor stages based on the top level
select.  I can make the dynamically created select list, but can''t save
the data from the form.  The code snippet I''m posting doesn''t
do exactly
that.  It just tries to print the selected item from the dynamically
created list.  I''m including the relevant parts of the views and
controller.
Thanks for your help.
primary_tumor_controller.rb
def new
   params[:user_id] = "1"
   params[:patient_id] = "1"
   @cancer_sites = MedicalTerm.find_all_by_semantic_class("cancer
type")
   @t_stages = ""
   @primary_tumor = PrimaryTumor.new
  end
  def provide_t_stage
    unless params[:primary_tumor_tumor_site].blank?
    @t_stages = MedicalTerm.find_all_by_semantic_features("[tumor
classification][#{params[:primary_tumor_tumor_site]}][t stage]")
             render :partial=>''provide_t_stage'',
           :locals => {:t_stages => @t_stages}
    end
  end
  def t_stage_selected
    render :partial => ''t_stage_selected'',
           :locals => {:t_stage_selected =>
params[:primary_tumor_t_stage]}
  end
new.rhtml
<h1>Create Primary Tumor</h1>
<% form_for :primary_tumor do |form| %>
<p><label for="primary_tumor_site">Tumor
site</label><br/>
<%= collection_select :primary_tumor, :tumor_site, @cancer_sites, :name,
:name %>
</p>
<div id="t_stage">
<%= "??" %>
</div>
<div id="t_stage_selected">
  <%= "??" %>
</div>
<%= observe_field ''primary_tumor_tumor_site'',
                  :update => ''t_stage'',
                  :url => {:action => ''provide_t_stage'',
:only_path =>
false},
                  :with =>
"''primary_tumor_tumor_site='' +
encodeURIComponent(value)" %>
<%= observe_field ''primary_tumor_t_stage'',
                  :update => ''t_stage_selected'',
                  :url => {:action =>
''t_stage_selected'', :only_path =>
false},
                  :with => "''primary_tumor_t_stage='' +
encodeURIComponent(value)" %>
<%= link_to ''Create'', :url => {:action =>
''create''} %>
<% end %>
<%= link_to ''Show'', :action => ''show'',
:id => @primary_tumor %>
_provide_t_stage.rhtml
<p><label for="primary_tumor_t_stage">T
stage</label><br/>
<%= collection_select :primary_tumor, :t_stage, @t_stages, :name, :name
%>
</p>
_t_stage_selected.rhtml
<%= @t_stage_selected %>
-- 
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
-~----------~----~----~----~------~----~------~--~---