Hi I hava a page where there is two combo box displayed and one updates
the other and it uses observe_field and partials. The page is not the
index page so its link is http://localhost:3000/user/online_booking. But
while designing I started off without the index page so I directly typed
the above link to test. But now I am keeping the index page and linking
this page from index with link_to. The strange thing is, if I still
directly type the above link and test, the update thing works great but
if I first open the index page and then go to this page from there, the
update doesn’t work at all. So, please help me figure out where I did
wrong, I just couldn’t seem to figure out…Heres the code:
IN CONTROLLER (user_controller.rb)
class UserController < ApplicationController
def index
end
def online_booking
end
def update_campsites
@resultset=[]
@result = Campsite.find_by_sql("select * from campsites where
walk_id = "+params[“id”])
for results in @result
@resultset << [results.camp_location, results.camp_location]
end
render :partial => ‘campsites’, :layout => false
end
IN VIEW (online_booking.rhtml)
Locations
<%= select(:selected, :location, Greatwalk.find_available_locations,
{:prompt=>'Select Great Walk Location'}, :id => :great_walks) %>
Campgrounds
<%= select("selected","campsites", %w{ -- }, :class =>
"select_campsites") %>
IN PARTIAL (_campsites.rhtml)
Campgrounds
<%=select "selected", "campsite", @resultset %>
IN VIEW (index.rhtml)
…
<%=link_to(“Fraser Island”, :action=>“online_booking”)%>
…
In the above online_booking.rhtml Greatwalk is a model where there is a
method find_available_locations.
Any suggestions… thank you.