我正在尝试按Date()进行分组.我在created_at列中有3条记录:
2011-12-03 08:00:24, 2011-12-03 08:12:10, 2011-12-04 09:00:00
Run Code Online (Sandbox Code Playgroud)
我想只按年,月,日分组,不分时间.所以对于上面的例子.它应该只返回两行:
2011-12-03 and 2011-12-04
Run Code Online (Sandbox Code Playgroud)
我该怎么办呢?
我有一张表可以跟踪文章视图.它包含以下列:
id, article_id, day, month, year, views_count.
Run Code Online (Sandbox Code Playgroud)
假设我想跟踪每篇文章的每日观看次数.如果我有1000个用户写的文章.行数将计算为:
365 (1 year) * 1,000 => 365,000
Run Code Online (Sandbox Code Playgroud)
哪个也不错.但是,请说.文章数量增长到1M.随着时间的推移,到了3年.行数将计算为:
365 * 3 * 1,000,000 => 1,095,000,000
Run Code Online (Sandbox Code Playgroud)
显然,随着时间的推移,这张桌子将继续增长.并且非常快.这会引起什么问题?或者我不应该担心,因为RDBM处理这种情况很常见?
我计划在报告中使用观看数据.要么将其分解为数月甚至数年.我应该担心表中的1B +行吗?
Resque正在返回Mysql2 ::错误:关闭MySQL连接:SHOW FIELDS FROM users
Worker
8608f362-819b-4c15-b42b-69c4df00d27b:1 on low at about 16 hours ago
Class
AddLiveView
Arguments
4383
{"remote_ip"=>"184.72.47.71", "expires"=>true}
Exception
ActiveRecord::StatementInvalid
Error
Mysql2::Error: closed MySQL connection: SHOW FIELDS FROM `users`
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/mysql2_adapter.rb:283:in `query'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/mysql2_adapter.rb:283:in `block in execute'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:244:in `block in log'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:239:in `log'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/mysql2_adapter.rb:283:in `execute'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/mysql2_adapter.rb:473:in `columns'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `block (2 levels) in initialize'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `with_connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:92:in `block in initialize'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:106:in `yield'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:106:in `default'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:106:in `block in initialize'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:717:in `yield'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:717:in `default'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:717:in `columns_hash'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/locking/optimistic.rb:145:in `locking_enabled?'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/relation.rb:110:in `to_a'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/relation/finder_methods.rb:376:in …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用rspec +制作进行简单的测试.不幸的是,没有太多体面的文章.
在spec/model/event_spec.rb中
require 'spec_helper'
describe Event do
subject { Fabricate(:event) }
describe "#full_name" do
its(:city) { should == "LA" }
end
end
Run Code Online (Sandbox Code Playgroud)
在spec/fabricators/event_fabricator.rb中
Fabricator(:event) do
user { Fabricate(:user) }
# The test works if I uncomment this line:
# user_id 1
city "LA"
description "Best event evar"
end
Run Code Online (Sandbox Code Playgroud)
在spec/fabricators/user_fabricator.rb中
Fabricator(:user) do
name 'Foobar'
email { Faker::Internet.email }
end
Run Code Online (Sandbox Code Playgroud)
我一直在:
1) Event#full_name city
Failure/Error: subject { Fabricate(:event) }
ActiveRecord::RecordInvalid:
Validation failed: User can't be blank
Run Code Online (Sandbox Code Playgroud)
PS如果有人知道任何在线文章/教程值得阅读关于rspec和制作的入门.请告诉我
我们正在将文件从HTTP uri方案上传到我们的S3.这意味着,我们的上传器脚本在我们的服务器中.我们使用S3相应地签署表格.我们的crossdomain.xml文件如下所示:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>
Run Code Online (Sandbox Code Playgroud)
我应该secure="false"进去allow-access-from吗?例如:
<allow-access-from domain="*" secure="false" />
Run Code Online (Sandbox Code Playgroud)
有什么含义secure="false"?我已经读过这个和这个,但是不太了解它.
第二,应该domain=*是一个真正的域名?即我们的域名?那么http://foobar.com和http://www.foobar.com?
我已经通过http://emacsformacosx.com/安装了Emacs
在 ~/.emacs.d/init.el
(tool-bar-mode -1)
(toggle-frame-maximized)
Run Code Online (Sandbox Code Playgroud)
它应该在启动时最大化Emacs。它进行了某种程度的最大化,但在顶部(菜单栏之间,Apple徽标下方)留有空隙。正如您在屏幕截图上所看到的:

如何确保Emacs填满屏幕。
PS,我不是从全屏模式看。
在Ember CLI应用程序中.如果有人想使用https://github.com/twbs/bootstrap/blob/master/js/tooltip.js
http://www.ember-cli.com/似乎没有提到任何具体的内容.
这个文件通常存储在哪里?乍一看,我正想着把它放进去public/assets/js.什么是惯例,如果有的话?
在一个余烬模板中.是否可以执行与伪代码类似的操作:
<ul>
{{#each [1..100] as |item|}}
<li>{{#link-to "articles.index" (query-params page=item)}}{{item}}{{/link-to}}</li>
{{/each}}
</ul>
Run Code Online (Sandbox Code Playgroud)
这将创建类似于:
<ul>
<li><a href="localhost/articles?page=1">1</a></li>
<li><a href="localhost/articles?page=2">2</a></li>
<li><a href="localhost/articles?page=3">3</a></li>
// so forth
</ul>
Run Code Online (Sandbox Code Playgroud) 我该怎么做:
{:foo => ['foo', 'bar'] }
Run Code Online (Sandbox Code Playgroud)
foo是一个实际的变量,它返回123.我真正想做的是:
{:1234 => ['foo', 'bar'] }
Run Code Online (Sandbox Code Playgroud) 有人使用http://github.com/manifestinteractive/jqvmap/吗?
这些工作:
$('#map').vectorMap('set', 'colors', { us: '#8EE5EE' });
$('#map').vectorMap('set', 'colors', { 'us': '#8EE5EE' });
Run Code Online (Sandbox Code Playgroud)
但是,这不是:
country_name = 'us';
$('#map').vectorMap('set', 'colors', { country_name: '#8EE5EE' });
Run Code Online (Sandbox Code Playgroud)
谁知道为什么?