本期由消失了一年多的 Daniel 和 Terry 共同主持
...
最简单地,先自己手写,然后自己调一调样式
<div class="form-group">
<label for="notary_name">Notary</label>
<span class="add-on"><i class="icon-search"></i></span>
<%= f.input_field :login, class: "span4 typeahead" %>
</div>
你要是想用 wrapper,那得自己实现一个 input
,但是如果只有个别地方有,我觉得你可以先手动写写好了,毕竟 simple_form 也就是抽象出了 wrapper 的概念,然后帮你输出一些 html。
如果你想深入了解 simple_form,simple_form 有许多文档,先通读上一遍。 https://github.com/plataformatec/simple_form/wiki
另外,我觉得你还可能需要再看看 Rails form_for 的文档,因为 simple_form_for 就是基于 form_for 的。 http://guides.rubyonrails.org/form_helpers.html http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html
我前阵子写了关于 simple_form 的博文,你可以在有一定的实践之后参考参考,文章里面讲了
http://justqyx.github.io/blog/2015/05/31/inspect-simple-form-1/ http://justqyx.github.io/blog/2015/05/31/inspect-simple-form-2/
如果有关于这两篇博文的问题,也欢迎在博文下面的评论留言。
#11 楼 @mouse_lin @zlx_star 强哥发句话容易么,你们这样人肉搜索,他可是我们伟大的 william 光头强
斌哥,容我没把代码仔细看完...
顶,到时候有录影么?
用 simple_form 你可以配一些 custom_wrapper
,再不济你还可以写一些 custom component
试试
Model.where("payload->'a' LIKE '%a%'")
http://www.postgresql.org/docs/9.4/static/hstore.html#AEN156883
我建议你评估这张表的数据规模及其增长速度,还有实际的功能需求。
对于经常使用的通过 offset limit,速度是相对比较慢的,当然这对于数据量小的表一般没有什么问题。 而对于数据规模稍微大的,像 rails 里每张表都会默认有个 id,那么毫无疑问,通过 where id > ? limit 的方式在记录数大的表里,在性能上的表现上是要远远优于 offset limit 的。
不靠谱
加内存,或者干掉一些内存占用较大的进程
我记得 elasticsearch-rails 这个 gem 在 rails 的 log 加了一些东西,如下图:
所以在理论是可以去 hack rails log 的,于是我找到了 Rails 打印这个 Log 地方,楼主可以根据这个一点点摸索回去
不过你可以参考这个,然后自己尝试将 request_id 加到 log tag 里去(我没有验证过 )
http://stackoverflow.com/questions/9582200/add-session-id-to-each-log-in-rails
不太明白你描述的究竟是怎么样的,能否贴一贴例子?例如说现有的日志是怎么样的,然后你想改成什么样的。
统一成 UTC,然后把数据洗一遍,显示的时候再根据当地的时区来显示
公司用了两年,现在换成直接在 gitlab 建个项目,维护文档
楼主可看一下我写的一篇博文:http://justqyx.github.io/blog/2014/11/04/tree-data/
经这么一介绍,对《Practical Object-Oriented Design in Ruby》这本书有兴趣; 而《Ruby Under a Microscope》这本在硬盘里躺了有一年了。 今年刚好适合看这两本书。
没用过 Simditor,不过你试试这样,使用迭代的方式对每一个 textarea 进行初始化
$(".rich_text_editor").each(function(index, dom){
new Simditor({
textarea: $(dom),
// ....
})
});
搞两个项目,两个都用一下就有体会了
个人认为,没啥好录的了。
讲 rails?有几本挺不错的书了。 讲一个 gem 如何使用?看文档就行了。 讲 ...,... 就行了。 讲 ...,... 讲了你也不懂。
#3 楼 @holysoros 另外,你的 1000 次 set 不能压缩?例如 1000 次的 incr key
,是可以换成 incrby key 1000
的
As of Ruby 1.9, Ruby uses native threads. Native threads means that each thread created by Ruby is directly mapped to a thread generated at the Operating System level. Every modern programming language implements native threads, so it makes more sense to use native threads. Here are some pros of native threads:
Pros
- Run on multiple processors
- Scheduled by the OS
- Blocking I/O operations don’t block other threads.
Even though have native threads in Ruby 1.9, only one thread will be executing at any given time, even if we have multiple cores in our processor. This is because of the GIL (Global Interpreter Lock) or GVL (Global VM Lock) that MRI Ruby (JRuby and Rubinius do not have a GIL, and, as such, have “real” threads) uses. This prevents other threads from being executed if one thread is already being executed by Ruby. But Ruby is smart enough to switch control to other waiting threads if one thread is waiting for some I/O operation to complete.
如上说的,在 Ruby 1.9 版本以后,I/O 密集型使用多线程是可以的,但是 CPU 密集型的 task,使用多线程就没有用了。 所以我认为,使用多进程来解决 CPU 密集型的任务是更好的方案,Resque 貌似使用的是多进程,而 sidekiq 采用的是多线程。至于是用队列还是直接写,还是怎么样的,根据你的应用的实际情况做相应的策略。
而你上面指出的 redisrb 这个 gem 的源码,redis server 那边因为是单线程模型运行,所以 redis client 是有可能会被阻塞住的。对于你外面的采用多线程,MRI 本身要进行调度,所以在你这种情况下多线程并没有单线程有优势。
Redis is a single-threaded server. It is not designed to benefit from multiple CPU cores. People are supposed to launch several Redis instances to scale out on several cores if needed. It is not really fair to compare one single Redis instance to a multi-threaded data store.
如上面说的,Redis 以单线程模型运行,不需要考虑并发读写的问题。