Ruby on rails rails jquery mobile重定向到错误的url
在rails 4 jQuery移动应用程序中,更新记录后,我的控制器重定向到索引(列表)页面,但在视图为索引时显示浏览器url 我认为答案是关闭Ajax,但我不知道如何将jQuery移动指令数据Ajax=“false”合并到rails表单帮助器中Ruby on rails rails jquery mobile重定向到错误的url,ruby-on-rails,jquery-mobile,Ruby On Rails,Jquery Mobile,在rails 4 jQuery移动应用程序中,更新记录后,我的控制器重定向到索引(列表)页面,但在视图为索引时显示浏览器url 我认为答案是关闭Ajax,但我不知道如何将jQuery移动指令数据Ajax=“false”合并到rails表单帮助器中 <%= form_for (@user) do |f| %> 浏览器中的视图:index.html.erb routes.rb: resources :users 控制器: def update respond_to do |for
<%= form_for (@user) do |f| %>
浏览器中的视图:index.html.erb
routes.rb:
resources :users
控制器:
def update
respond_to do |format|
if @user.update(user_params)
format.html { redirect_to users_path,
notice: "User #{@user.user_name} was successfully updated." }
else
format.html { render action: 'edit' }
end
end
end
解决方案是将数据url指令添加到我的布局中
<div data-role="page" id="home" data-url="<%= request.path %>">
通过@markhorrocks answer很好地工作。我的解决方案和你一样。只需在控制器中添加一个实例变量,如
@data\u url='/room'
,然后添加
ruby
<div data-role="page" id="home" data-url="<%= request.path %>">