Rails 3.1远程请求提交两次

时间:2022-12-07 00:12:26

I developed a Rails 3.1 application that consists of a 100% Ajax CRUD forms to input users and customers. I created two separate models, controllers, views etc. The views for each model contain jquery files for create edit update and destroy. The problem is when I perform any operation that performs a remote operation, it is called twice. I can confirm this happening in console view in firebug as well as output in WEBrick output. Can anyone assist in tracking down what happened here? What would cause rails to process each call twice?

我开发了一个Rails 3.1应用程序,它由100%的Ajax CRUD表单组成,用于输入用户和客户。我创建了两个独立的模型,控制器,视图等。每个模型的视图包含用于创建编辑更新和销毁的jquery文件。问题是当我执行任何执行远程操作的操作时,它被调用两次。我可以在firebug的控制台视图中确认这种情况以及WEBrick输出中的输出。任何人都可以帮助追踪这里发生的事情吗?什么会导致rails处理每次调用两次?

2 个解决方案

#1


13  

If you have precompiled the assets and running in development mode, then the JavaScripts will be included twice on the page.

如果您已预编译资产并在开发模式下运行,那么JavaScripts将在页面上包含两次。

Remove everything from public/assets if in development mode.

如果处于开发模式,从公共/资产中删除所有内容

#2


19  

Adding config.serve_static_assets = false to development.rb will prevent loading files from /public/assets.

将config.serve_static_assets = false添加到development.rb将阻止从/ public / assets加载文件。

Actually I need to precompile locally because my test mode is using only static assets from /public/assets - tests are catching possible production asset problems. How? Just set config.assets.compile = false and config.serve_static_assets = true in test.rb configuration.

实际上我需要在本地进行预编译,因为我的测试模式只使用来自/ public / assets的静态资产 - 测试正在捕捉可能的生产资产问题。怎么样?只需在test.rb配置中设置config.assets.compile = false和config.serve_static_assets = true即可。

#1


13  

If you have precompiled the assets and running in development mode, then the JavaScripts will be included twice on the page.

如果您已预编译资产并在开发模式下运行,那么JavaScripts将在页面上包含两次。

Remove everything from public/assets if in development mode.

如果处于开发模式,从公共/资产中删除所有内容

#2


19  

Adding config.serve_static_assets = false to development.rb will prevent loading files from /public/assets.

将config.serve_static_assets = false添加到development.rb将阻止从/ public / assets加载文件。

Actually I need to precompile locally because my test mode is using only static assets from /public/assets - tests are catching possible production asset problems. How? Just set config.assets.compile = false and config.serve_static_assets = true in test.rb configuration.

实际上我需要在本地进行预编译,因为我的测试模式只使用来自/ public / assets的静态资产 - 测试正在捕捉可能的生产资产问题。怎么样?只需在test.rb配置中设置config.assets.compile = false和config.serve_static_assets = true即可。