Hello,
I’ve seen numerous tutorials on this but have yet to get anything
working. It’s been about 5 days, and I am getting a little frustrated,
so here goes
Here is the model:
items has_many inventories
inventory has_many locations
locations has_many warehouses
Here is the view:
<%= javascript_include_tag :defaults %>
<% form_for (@item), :url=> {:action => “create”, :id => @user.id} do |
i| %>
<%= i.text_field :name %>
<%= render :partial=>‘getlocation’ %>
<%= submit_tag ‘Submit’ %>
<% end %>
getlocation.rhtml
Location: <%= collection_select :inventory, :location_id,
@locations, :id, :streetadrees1 %>
And the controller
def new
@location= Location.find(:first, :conditions=>[‘primaryloc=?’, ‘1’]
@locations = Location.find(:all)
@warehouse = Warehouse.find(:all, :conditions=>[‘location_id=?’,
@location.id])
@item = @business.items.build
end
def getlocation
@location = Location.find(params[:location_id])
@locations = Location.find(:all)
@warehouse = Warehouse.find(:all, :conditions=>[‘location_id=?’,
@location.id])
render :partial => ‘getwarehouse’
end
Results: The javascript does pass to the params to the server when the
location select menu changes, but the warehouse doesn’t seem to
collect the new data, and update its list. Any ideas? Thanks in
advance. (and yes, I need to use observe field, a totally client side
solution will not work for my purposes).