我遇到了ElasticSearch和Rails的问题,由于attr_protected,一些数据没有正确编入索引.Elastic Search在哪里存储索引数据?检查实际索引数据是否错误将很有用.
检查映射Tire.index('models').mapping没有帮助,列出该字段.
我想知道在使用ElasticSearch和Tire时如何在应用程序中测试搜索.
您如何设置新的ElasticSearch测试实例?有没有办法嘲笑它?
你知道的任何宝石可能对此有所帮助吗?
我发现一些有用的东西:
我发现了一篇很棒的文章回答了我所有的问题:)
http://bitsandbit.es/post/11295134047/unit-testing-with-tire-and-elastic-search#disqus_thread
此外,还有来自轮胎作者卡米的答案.
这也很有用:https://github.com/karmi/tire/wiki/Integration-Testing-Rails-Models-with-Tire
在问之前我无法相信我没有找到这些......
通过良好的语法,可以轻松地为类添加功能.
无论如何,在Rails 3.2中,不推荐使用InstanceMethods模块.如果我理解正确,我们应该只在(实际上它只是在模块的主体中):included块中定义我们的方法
# edit: don't do this! The method definition should just be in the body of the module
included do
def my_method; end
end
Run Code Online (Sandbox Code Playgroud)
我只是想知道是否有人知道他们为什么决定那样做?
ruby-on-rails activesupport ruby-on-rails-3 ruby-on-rails-3.2
假设我想在我的应用中搜索事件.当我显示结果时,我想显示例如创建事件的人.
有没有办法在.includes(:user)某处添加,以避免不必要的查询(每个事件一个)?我在文档中找不到它.我应该用事件索引用户名吗?但我必须保持用户信息最新...
谢谢
ruby-on-rails sunspot model-associations ruby-on-rails-3 sunspot-rails

有一种简单的方法以编程方式滚动谷歌地图的x像素?
我只能考虑使用setCenter,但问题是我必须根据缩放级别计算新位置(lat/lng)...
你能想到别的吗?告诉我,如果您对此非常肯定,使用Google Map API是不可能的.
ps:我正在使用Gmaps4rails,所以如果你能想到用宝石做到这一点的方法,它会很酷.(比如将边界调整为地图的子集.)因为最终我的目标是阻止菜单隐藏一些标记.我需要更改地图的视口,如果这是有意义的,那么它使标记适合橙色区域,而不是完整的地图.

解:
@Shane Best,很棒,这个想法很完美,但我认为你的解决方案适用于Google API v2,对吗?这是我为V3做的:
var point = map.getCenter();
var overlay = new google.maps.OverlayView();
overlay.draw = function() {};
overlay.setMap(map);
var projection = overlay.getProjection();
var pixelpoint = projection.fromLatLngToDivPixel(point);
pixelpoint.x += my_value; # or .y
point = projection.fromDivPixelToLatLng(pixelpoint);
map.setCenter(point);
Run Code Online (Sandbox Code Playgroud)
如果有人知道有关API v3的更好的解决方案,请告诉我们.
编辑:似乎Facebook终于修复了这个错误!
你能帮我理解为什么会这样吗:
这是一个带有图片的公共活动:https: //www.facebook.com/events/282054218538223
但是当我尝试访问http://graph.facebook.com/282054218538223/picture时,我得到的只是默认图片.
这是另一个公共活动:http://www.facebook.com/events/266496120103339
但这一次,访问http://graph.facebook.com/266496120103339/picture会返回活动照片.
这2个事件有什么区别?
我有一个返回JSON的API,它没有为Ember的消费格式正确.而不是这(烬预期):
{ events: [
{ id: 1, title: "Event 1", description: "Learn Ember" },
{ id: 2, title: "Event 2", description: "Learn Ember 2" }
]}
Run Code Online (Sandbox Code Playgroud)
我明白了:
{ events: [
{ event: { id: 1, "Event 1", description: "Learn Ember" }},
{ event: { id: 2, "Event 2", description: "Learn Ember 2" }}
]}
Run Code Online (Sandbox Code Playgroud)
因此,如果我理解正确,我需要创建一个自定义Serializer来修改JSON.
var store = DS.Store.create({
adapter: DS.RESTAdapter.create({
serializer: DS.Serializer.create({
// which hook should I override??
})
})
});
Run Code Online (Sandbox Code Playgroud)
我已经阅读了与DS.Serializer相关的代码注释,但我无法理解如何实现我想要的...
我该怎么做?
ps:我的目标是App.Event.find()开展工作.目前,我明白了Uncaught Error: assertion …
我有一个twitter bootstrap模式的问题...
当我的元素上没有.fade类时,它工作正常.一旦我添加它,模态就不会显示出来.
我想到了这个问题,我想:
doAnimate ?
this.$backdrop.one(transitionEnd, callback) :
callback()
Run Code Online (Sandbox Code Playgroud)
.fade是的doAnimate,它看起来很好.但我认为webkitTransitionEnd永远不会被解雇,因为我尝试在回调中记录某些内容,并且它永远不会被记录.
有任何想法吗?
编辑:一些代码
链接:
<a href="/events/2-fefewfewfe/rsvps" data-backdrop="true" data-controls-modal="event-modal" data-keyboard="true">I'm attending!<span class="ico join"></span></a>
Run Code Online (Sandbox Code Playgroud)
模态(没有淡入淡出类,在我添加时不起作用)
<div id="event-modal" class="modal hide fade"></div>
Run Code Online (Sandbox Code Playgroud)
css:
.modal.fade {
-webkit-transition: opacity .3s linear, top .3s ease-out;
-moz-transition: opacity .3s linear, top .3s ease-out;
-ms-transition: opacity .3s linear, top .3s ease-out;
-o-transition: opacity .3s linear, top .3s ease-out;
transition: opacity .3s linear, top .3s ease-out;
top: -25%;
}
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?
谢谢.
我在我网站的主页上使用ElasticSearch.在我的验收测试中,当用户登录时,他被重定向到主页.
但是在测试中使用ES是昂贵的(需要创建和删除索引),因此我不希望每次用户浏览主页时都这样做.
我想只在测试有一些元数据时才进行实际的ES搜索:
config.before(:each) do
if example.metadata[:elastic]
Model.create_elasticsearch_index
end
end
scenario "Results should be ordered by distance", :elastic do
# tests...
end
Run Code Online (Sandbox Code Playgroud)
因此,我需要"模拟"搜索,而不是在测试没有弹性元数据时使用ES.
什么是实现这一目标的好方法?
api ×2
rspec ×2
tire ×2
dom-events ×1
ember-data ×1
ember.js ×1
facebook ×1
gmaps4rails ×1
google-maps ×1
javascript ×1
jquery ×1
oauth ×1
oauth-2.0 ×1
scroll ×1
security ×1
sunspot ×1