开发者

How to update data in page after redirect

开发者 https://www.devze.com 2022-12-19 16:32 出处:网络
On the change of a \'开发者_StackOverflowselect\', I\'m calling a method in my controller, \'get_sched\'.

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

精彩评论

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

关注公众号