Ruby on rails Rails-显示的URL与页面加载不同
我在rails 3应用程序上使用mobile_detection为移动用户提供单独的页面。我正在通过Safari中的用户代理进行测试。问题是在我的一个进程中,rails向web浏览器URL栏发布的URL与它实际加载的页面不同。因此,如果我刷新页面,它会尝试转到它放在web栏中的错误URL 以下是过程Ruby on rails Rails-显示的URL与页面加载不同,ruby-on-rails,jquery-mobile,model-view-controller,controller,Ruby On Rails,Jquery Mobile,Model View Controller,Controller,我在rails 3应用程序上使用mobile_detection为移动用户提供单独的页面。我正在通过Safari中的用户代理进行测试。问题是在我的一个进程中,rails向web浏览器URL栏发布的URL与它实际加载的页面不同。因此,如果我刷新页面,它会尝试转到它放在web栏中的错误URL 以下是过程 用户提交参与表格 “参与控制器”保存记录,然后呈现移动版或html版的团队候选人 以下是进程的服务器日志,其中排除了一些详细信息 Started POST "/participations"
Started POST "/participations" for 127.0.0.1 at 2013-07-20 00:14:37 -0400
Processing by ParticipationsController#create as HTML
...Commits to DB
Redirected to http://localhost:3000/teams/57/candidate
Started GET "/teams/57/candidate" for 127.0.0.1 at 2013-07-20 00:14:37 -0400
Processing by TeamsController#candidate as HTML
Rendered teams/candidate.mobile.erb within layouts/application (34.9ms)
当我从桌面运行同一进程时,不会发生错误。作为一个夏天的问题:
respond_to do |format|
if @participation.save
if mobile_device?
format.mobile {redirect_to candidate_team_path(@team), notice: 'You have joined the team!'}
else
format.html { redirect_to candidate_team_path(@team), notice: 'You have successfully joined the team.' }
end
else
if @participation.team_id.nil?
format.mobile { redirect_to :back, notice: 'No team was joined.' }
format.html { redirect_to :back, notice: 'No team was joined.' }
format.json { render json: @participation.errors, status: :unprocessable_entity }
else
if mobile_device?
format.mobile {redirect_to candidate_team_path(@team), notice: 'Welcome back.'}
else
format.html {redirect_to candidate_team_path(@team), notice: 'Welcome back.'}
end
end
end
end
结束一个伟大的解决方案 希望这对其他人有帮助。解决方案是在主布局中手动设置URL。考虑到JQM使用页面缓存和内部/外部页面加载的方式,这对于某些页面加载是必需的 这可以放在application.mobile.erb中
<div data-role="page" data-url="<% request.fullpath %> "