How to update data in page after redirect
On the change of a '开发者_StackOverflowselect', I'm calling a method in my controller, 'get_sched'. That method just sets a couple variables, then I do a redirect with:
respond_to do |format|
format.html { redirect_to :action => "index", :id => params[:id] }
end
My log shows that it's redirecting, but the data on my page isn't updating. Do i need to do something else to make it update?
Changing a select implies you are doing an ajax call, in which case the page won't redirect. Either submit the form, or change your display logic so it doesn't need to redirect.
The ajax call requires special handling if you need to redirect the whole page.
Try this:
respond_to do |format|
format.html do
render :update do |page|
page.redirect_to :action => "index", :id => params[:id]
end
end
end
精彩评论