I have a view, seen below, that shows a list of churches if the zip
code isn’t 01540 or 01537. This part works perfectly. The problem is
that this is the page is to edit an existing record also, so
observe_field needs to see that the zip code currently doesn’t match,
so the church list needs to be shown. Currently, even if the zip
doesn’t match, the list will only be shown after the field is changed,
even is the field is changed to the same value… Here is the view,
controller code and church_select view in that order… Please give me
a direction to look…
Thanks
View
<% fields_for @household, :builder => TaggedBuilder do |
household_form| %>
<%= household_form.text_field :first_name, :maxlength => 50, :size => 15, :autocomplete => "off", :class => 'household ' %> <%= household_form.text_field :middle, :size => 1, :maxlength =>1, :autocomplete => "off", :class => 'household ' %> <%= household_form.text_field :last_name, :maxlength => 50, :size => 20, :autocomplete => "off", :class => 'household ' %> <%= household_form.text_field :address, :autocomplete => "off", :class => 'household ' %> <%= household_form.text_field :zip, :size=> 5, :autocomplete => "off", :class => 'household ' %> <%= household_form.text_field number_to_phone(:phone, :area_code => true), :autocomplete => "off", :size => 14, :class => 'household ' %><%= observe_field :household_zip, :url => {:controller => 'households', :action => 'watch_church'}, :update => :church, :with => ':zip', :frequency=> 0.5 %>Federal Programs Primary Income <%= household_form.select(:primary, [['1. Employment', 1],['2. Unemployment', 2],['3. SSI', 4],['4. TANF/EADC', 8],['5. Other', 16], ['6. None', 32]], :class => "household ") %><% end %>
controller
def watch_church
# debugger
if (params[‘:zip’] != “01540”) && (params[‘:zip’] != “01537”)
then
render :partial => “church_select”
else
render(:nothing=>true)
end
endchurch_select view
Member of Local Church: <%= collection_select(‘household’,
‘church_id’, Church.find(:all), ‘id’, ‘name’) %>
<%= household_form.check_box :food_stamps %> |
<%= household_form.check_box :wic %> |
<%= household_form.check_box :school_breakfast %> |
<%= household_form.check_box :school_lunch %> |
<%= household_form.check_box :SFSD %> |