开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜