:自从我安装了 Bundler 后,Rails 2.3.9 上的 order 根本无法工作?
已解决,见下文。
我的应用程序位于 Heroku 上,他们最近乘坐了“.gems” 文件以将“Gemfile”与 Bundler 一起使用。
注意: 我回到旧的 gem 系统,问题仍然存在。现在本地也有同样的问题。
我进行了更改,一切似乎都工作正常,直到我注意到 :order 不再工作。
在控制台中
Users.find(:all)
User Load (13.3ms) SELECT * FROM `users`
User Columns (2.2ms) SHOW FIELDS FROM `users`
然后如果我这样做
Users.find(:all, :order => "'created_at' ASC")
User Load (13.3ms) SELECT * FROM `users`
并且将返回相同的结果
Named_scope 和使用 :order 的所有内容都不再起作用。我必须使用 find_by_sql 对 SQL 请求进行硬编码来临时修复它。
任何帮助将不胜感激...
谢谢。
更新:
require 'rubygems'
source 'http://rubygems.org'
#source 'http://gemcutter.org'
#source 'http://gems.github.com'
gem 'rails', '2.3.9'
gem "bundler", "~> 1.0.15"
gem "builder", "3.0.0"
gem 'delayed_job', '2.0.7'
gem "hashie", "0.4.0"
gem "httparty", "0.6.1"
#gem "httparty", "0.5.0"
gem 'dalli' , '1.0.2'
gem 'calendar_date_select' , '1.16.1'
gem 'ckeditor' , '3.4.3'
gem 'fastercsv'
gem 'geokit' , '1.5.0'
gem 'hpricot' , '0.8.2'
gem 'will_paginate' , '2.3.14'
gem 'feed-normalizer' , '1.5.2'
gem 'memcached-northscale' , '0.19.5.3'
gem 'mysql' , '2.8.1'
gem 'less' , '1.2.21'
gem 'aws-s3'
gem 'paperclip'
gem 'pdfkit' , '0.4.6'
gem 'icalendar' , '1.1.5'
gem 'sitemap_generator'
gem 'taps' , '0.3.23'
gem 'geo_ip' , '0.3.1'
gem 'i18n'
更多示例
User.find(:all,{ :order => "CREATED_AT DESC",:test => ""})
ArgumentError: Unknown key(s): test
User.find(:all,{:order => "CREATED_AT DESC"})
User Load (13.3ms) SELECT * FROM `users` (no order)
User.find(:all,{ :order => "CREATED_AT DESC",:conditions => "SCORE > 10000"})
User Load (13.3ms) SELECT * FROM `users` WHERE `score` > 10000 (no order again)
更多信息
- 回到 2.3.8 没有帮助
- :条件有效,但无效:offset
- 我的其他本地应用程序工作正常
SOLVED, see below.
My app is on Heroku and they recently took a ride of the ".gems" file to use "Gemfile" with Bundler.
Note: I went back to the old gem system and the problem is still there. Same problem locally too now.
I made the change and everything seemed to work fine till I notice :order was not working anymore.
In the console
Users.find(:all)
User Load (13.3ms) SELECT * FROM `users`
User Columns (2.2ms) SHOW FIELDS FROM `users`
And then after if I do
Users.find(:all, :order => "'created_at' ASC")
User Load (13.3ms) SELECT * FROM `users`
And will return the same results
Named_scope and everything using :order doesn't work anymore. I had to hardcode the SQL request using find_by_sql to fix it temporarily.
Any help will be highly appreciated...
Thanks.
Updated:
require 'rubygems'
source 'http://rubygems.org'
#source 'http://gemcutter.org'
#source 'http://gems.github.com'
gem 'rails', '2.3.9'
gem "bundler", "~> 1.0.15"
gem "builder", "3.0.0"
gem 'delayed_job', '2.0.7'
gem "hashie", "0.4.0"
gem "httparty", "0.6.1"
#gem "httparty", "0.5.0"
gem 'dalli' , '1.0.2'
gem 'calendar_date_select' , '1.16.1'
gem 'ckeditor' , '3.4.3'
gem 'fastercsv'
gem 'geokit' , '1.5.0'
gem 'hpricot' , '0.8.2'
gem 'will_paginate' , '2.3.14'
gem 'feed-normalizer' , '1.5.2'
gem 'memcached-northscale' , '0.19.5.3'
gem 'mysql' , '2.8.1'
gem 'less' , '1.2.21'
gem 'aws-s3'
gem 'paperclip'
gem 'pdfkit' , '0.4.6'
gem 'icalendar' , '1.1.5'
gem 'sitemap_generator'
gem 'taps' , '0.3.23'
gem 'geo_ip' , '0.3.1'
gem 'i18n'
More examples
User.find(:all,{ :order => "CREATED_AT DESC",:test => ""})
ArgumentError: Unknown key(s): test
User.find(:all,{:order => "CREATED_AT DESC"})
User Load (13.3ms) SELECT * FROM `users` (no order)
User.find(:all,{ :order => "CREATED_AT DESC",:conditions => "SCORE > 10000"})
User Load (13.3ms) SELECT * FROM `users` WHERE `score` > 10000 (no order again)
More Info
- Moving back to 2.3.8 did not help
- :conditions works but not :offset
- My other local apps works properly
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我在 4 小时的狩猎后发现了问题。
结果我在安装 Bundler 后没有删除供应商。其中之一是 https://github.com/xymbol/active_record_random 并搞砸了 Active Record。
谢谢大家,特别是@mu太短了
Okay I found the problem after 4h of hunting.
Turns out I didn't delete the vendors after installing Bundler. One of them was https://github.com/xymbol/active_record_random and screwed up Active Record.
Thanks everyone, particularly @mu is too short