Hi
I am probably doing something stupid, but I have something really weird
going on. I am using form_remote_tag (in a page called form), my code
essentially goes:
form_remote_tag
My code
end_form_tag
Then in the controller, under certain conditions I have a redirect_to
This works fine until the redirect_to
On redirect it shows the contents of the new page (login), but this is
not in the source code! The URL does not change to login (it remains
form) and thus the form does not work.
Basically, I just want the controller to forget all form stuff and
redirect properly.
Does anyone have an idea on this one?
Thanks
Darren
View:
<%= form_remote_tag :update => "counties", :url => { :action =>
"form" } %>
Please select
<%= options_from_collection_for_select @counties, "id",
"county_name", @county_id.to_i%>
<%= options_from_collection_for_select @districts, "id", "district_name", @district_id.to_i%>
onchange=“this.form.onsubmit();”> |
controller:
def form
@counties=Countyname.find(:all, :order =>“county_name”,
:conditions=>[“language_id = ?”, session[:language_id]])
if request.post?
@county_id=Countyname.find(:first, :conditions => [“county_id = ?”,
params[:form].to_i]).id
end
@districts=District.find(:all, :order => “district_name”,
:conditions=>[“county_id = ?”, @county_id])
if request.post?
@dist=District.find(:first, :conditions => [“id = ? and county_id =
?”, params[:form2].to_i, @county_id])
if (@dist)
@district_id [email protected]
else
@district_id=District.find(:first, :conditions => [“county_id =
?”, @county_id]).id
end
end
if (@district_id && @county_id)
@places=Place.find(:all, :order => “institution_id”, :conditions =>
[“district_id = ?”, @district_id])
@institutions=[]
for place in @places
@res=Institution.find(:first, :conditions=>[“id = ?”, place.id])
@institutions << @res
if request.post?
@institution_id=params[:form3]
end
end
if !(@institution_id.nil?) && (@district_id && @county_id &&
!@institution_id.empty?)
redirect_to(:controller => “login”, :action => “login” )
end
end
end