好的,当我尝试使用资产管道时,我收到此错误.我不明白是什么导致了它.
Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError in Photos#show
Showing .../app/views/photos/_photo_view.html.haml where line #2 raised:
jquery.autocomplete isn't precompiled
Extracted source (around line #2):
1: - content_for :scripts do
2: = javascript_include_tag 'jquery.autocomplete'
Run Code Online (Sandbox Code Playgroud)
但是,这是预先编译的.我rake assets:precompile RAILS_ENV=production在启动服务器之前跑了,在我的public/assets目录中我有文件:jquery-5550a245a55b28927b5552cac182e612.autocomplete.js以及它.js.gz,它准确地反映在清单中:
#manifest.yml
---
application.js: application-4277323e3f7506b71f45c71e8a3a7c8f.js
jquery.autocomplete.js: jquery-5550a245a55b28927b5552cac182e612.autocomplete.js
jquery.cycle.all.min.js: jquery-183ef696b43944deaee5778d3094dbdd.cycle.all.min.js
jquery.fancybox.js: jquery-e52e44b2b4fb349bade9beb91461a810.fancybox.js
jquery.plupload.queue.js: jquery-f2e7f6ad7d2e5ca50235ed21f8d573cc.plupload.queue.js
jquery.tools.js: jquery-c53e304240fa56767fe0f2a00cb4bceb.tools.js
plupload.full.js: plupload-5dd26ee3fff6b627c19f196e9d1429dd.full.js
application.css: application-ce5217e1714cbc4e9c3ff6c5dfc9b221.css
fancybox.css: fancybox-9ee9c36f391086e4b0629b7df4042390.css
jquery.plupload.queue.css: jquery-661fbf3f503aa32ff11c004838c0820b.plupload.queue.css
jquery.js: jquery-4d23f0cfea862f56deb04f0a8ab1fcee.js
jquery.min.js: jquery-8a50feed8d29566738ad005e19fe1c2d.min.js
Run Code Online (Sandbox Code Playgroud)
有问题的javascript文件没有加载到我的application.js文件中,因为我只需要在一个视图上使用它,不要在应用程序的任何其他地方使用它.为了解释这一点(并修复链接尝试编译sass部分)我配置了我的预编译regexp,如下所示:
#environments/production.rb
config.assets.precompile = [/^[a-zA-Z]*\..*/]
Run Code Online (Sandbox Code Playgroud)
(上面的regexp预编译任何以字母字符开头的文件,并忽略以非字母字符开头的文件,如下划线).
有没有人能够了解导致这种情况的原因以及如何解决这个问题?资产管道让我脱掉了头发!
刚刚发现Rails.configuration.assets.digests在生产中返回nil.也许问题存在,由于某种原因,链轮没有找到manifest.yml.
我可能错了,但看起来sprockets在查找manifest.yml时没有在config中使用assets_host.
https://github.com/rails/rails/blob/3-2-stable/actionpack/lib/sprockets/railtie.rb#L38
我有2个表,用户和以下.table follow有一个名为status的列.我想计算每个用户按状态分组的次数.
下面的查询返回每个用户的每种状态类型的记录.
SELECT users.name as user_name, f.status, count(f.id)
FROM users
JOIN application_follows f ON f.user_id = users.id
GROUP BY users.id, f.status
ORDER BY users.id
Run Code Online (Sandbox Code Playgroud)
返回类似于:
user_name status count
mike new 10
mike old 5
tom new 8
tom old 9
Run Code Online (Sandbox Code Playgroud)
但我想要一些更友好的东西:
user_name status_count
mike new,10|old,5
tom new,8|old,9
Run Code Online (Sandbox Code Playgroud)
尝试使用group_concat并计数但没有工作.有线索吗?
我建立与elasticsearch自动完成搜索,所以我需要查询3个指标posts,comments,authors。我有以下查询:
{
"query":{
"query_string":{
"query":"something"
}
}
}
Run Code Online (Sandbox Code Playgroud)
电话:
curl -X GET 'http://localhost:9200/posts,comments,authors/_search?pretty' -d '{
"query": {
"query_string": {
"query": "something"
}
}
}'
Run Code Online (Sandbox Code Playgroud)
我需要按特定的索引字段对结果进行排序,例如:
帖子索引有一个名为comments_count,评论votes_count和作者的字段posts_count。比较帖子时,则应按,然后是comments_count评论,然后是votes_count作者posts_count。
可以这样做吗?我不想将索引合并为一个,因为它们索引完全不同的文档。