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)
================================================================================
<p>
    <label for = "walk location">Locations</label><br />
    <%= select(:selected, :location, Greatwalk.find_available_locations,
        {:prompt=>'Select Great Walk Location'}, :id => :great_walks) %>
</p>
    <%= observe_field("great_walks", :url => {:controller => "user",
:action => "update_campsites"},
              :update => "campsites_list", :with => "id")%>
<div id ="campsites_list" >
  <p>
       <label for = "state">Campgrounds</label> <br />
         <%= select("selected","campsites", %w{ -- }, :class =>
"select_campsites") %>
    </p>
</div>
    <%=button_to "Add to Cart", :action => :add_to_cart, :id =>
"campsites"%>
================================================================================

IN PARTIAL (_campsites.rhtml)
================================================================================
<p>
  <label for="camp location">Campgrounds</label><br/>
  <%=select "selected", "campsite", @resultset %>
</p>
================================================================================

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.
-- 
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to