用angular 做了3个项目(一个自己做,另外两个我带着项目组中其他人做)。 遇到的问题是:  ( after 3 projects using angular, we met this problem: ) 随着项目的增长,自动化测试(单元测试/功能性测试) 越来越重要。 对model的测试不多, 因为model仅仅是对DB的封装。 而且没啥太多逻辑。 逻辑都集中在 lib 中...
Callbundleincapistrano+rbenv(capstrano+rbenv,bundle问题)
it's very easy. 1. make sure you have "rbenv" and a ruby version (e.g. 1.9.3) installed in remote server 2. in your config/deploy.rb (capistrano file)  require 'capistrano-rbenv' 3. in your Ge...
Reduceinject方法的用法(theusageofreduceinjectinruby)
用了5年RUBY了,今天居然头一回遇到这个情况:   需要对某个数组中的所有操作进行   的操作。 ( For the past years, I have not met this kind of questions until this morning, I need to loop all the elements of an array and return an...
Rbenv+passenger:nosuchfiletoload:rubygemspath_support
refer to: http://stackoverflow.com/a/15777738/445908 In my case, I also met this problem: ( My environment: Centos 5.8, rbenv 1.9.3p327, passenger 3.0.19, nginx( compiled and installed by passen...
Rbenv的流行果然是有原因的(rbenvismuchgreaterthanrvminsomecituation)
前天晚上在一台centos 5.8上安装ruby,  rvm 完全不行(没有git 模块,它跟我抱怨。我手动安装了GIT后,它还是跟我抱怨。我无视抱怨,继续按照ruby 1.9.3时,出错。还是因为GIT。我了歌曲。)我用了4个小时。 结果无奈之下转向rbenv.  rbenv 很快搞定。(我第一次读github上的文档。。按照它的描述,15分钟搞定,没遇到任何问题): ...
Rails4取消turbolinks(removeturbolinksfromrails4)
turbolinks 的作用是为了加快js的加载。把它放到了cache中。   ( it's said that using turbolink makes your browser loading js/css faster)  我觉得很不爽,很多时候都会使我的JS出现莫名其妙的问题。   ( but I don't like it since it make...
Railsmacro如何定义?wheretodefinemacrosinrails?
http://stackoverflow.com/questions/926489/rails-macro-style-functions 如何定义rails macro? 上面的文章描述的很全面了。 对于controller使用的,就定义在application controller中。对于model会使用的,就reopen activerecord::base For model...
如何打印可读性强的json:(pretty Readablejsoninruby)
http://stackoverflow.com/questions/86653/how-can-i-pretty-format-my-json-output-in-ruby-on-rails 43 json = Cms::Utils.object(videoid) 44 logger.info "== json for url( #{url}) : #{JSON.p...
Fromrailstodjango(viceversa)从rails到django(反之亦然)
checkout this post:    http://blog.jupo.org/2011/07/30/rails-quick-start-for-djangonauts/ July 30, 2011  /  Home I recently started a new role at a Ruby on Rails shop, which a...
Forchineservmusers:ruby.taobao.org
国内的同学门,安装 RVM之后记得走淘宝哦~    安装各种rubygem也可以~~~ 详情见:  ruby.taobao.org 复制过来的内容: $ gem sources --remove https://rubygems.org/$ gem sources -a http://ruby.taobao.org/$ gem sources -l*** CUR...
Rails中手动开关connection(closeopenconnectionsinrails)
for details, please refer to : http://blog.daniel-azuma.com/archives/216 connection = User.connection obj = User.find(1) connection = obj.connection User.clear_active_connections! $ show  ...
Rails中使用cache(最简单的)(cachinginrailsfordifferentparameters)
http://stackoverflow.com/questions/1988658/rails-action-caching-with-querystring-parameters 1. in production.rb, : config.action_controller.perform_caching = true 2. in your controller : (will...
Rails中使用uploadify插件(usinguploadifyinrails3)
这个插件非常好用。 可以看作是 SWFupload的后续 (SWFUPLOAD已经停止开发好久好久了) 使用步骤也是一般吧,不是一下就可以搞定(我昨天花了大半天时间才做了个满意的封装,虽然我很讨厌封装),但是也不是特别麻烦。可以说解藕做的不错~   实现它的缘由1. 由于我们的图片都保存在一个远程服务器上,所以我们不需要在本地永久保存上传的数据。 对应的数据库中的列也只是一个Str...
Rubyseleniumgem:selenium Webdriver(复制过来的文档)
 官方文档挂了,所以我就复制过来了。看起来很有效。( copied from other site because it seems that we can't access its official site from China mainland )  Introduction The Ruby bindings for Selenium/WebDriver...
测试文件上传(testfileuploadinrails)
非常简单。 You can use fixture_file_upload method to test file uploading: Put your test file in "{Rails.root}/spec/fixtures/files" directory before :each do @file = fixture_file_upload('files/test_...
Rubyonlyincludemodule1time(preventincludingamodulemultipletimes)
approaches: 1. use raw ruby ( not recommended)    2. use ActiveSupport::Concern ( http://api.rubyonrails.org/classes/ActiveSupport/Concern.html ) p.s. 3. require_dependency ...
Capistrano中的logger,set Before(capistranobasicusages)
Capistrano 灰常好用。 不过有几个常用的用法还是要留意一下: 参考这个文章: http://stackoverflow.com/questions/4294970/rails-3-capistrano-tutorial-to-deploy-to-server-using-git http://www.aaginskiy.com/technology/2011/02/d...
Ruby操作zookeeper的比较(zookeeperrubyclientscomparison)
为了寻找一个比较合适的RUBY ZOOKEEPER客户端,搜索了一下。( I am involving a project that uses zookeeper as a component and I am looking for a suitable ruby client for zookeeper. and I googled around with the results bel...
Encodingprobleminruby(ruby中的汉字转换)
Today I am face a problem:  how to convert 汉字 to \uxxx\uxxx ?  after googled and quickly browsed several posts, I found this answer:   Using active support:  >> require ...
使用request Log Analyzer分析rails日志(usingrequest Log Analyzertoanalyzeyourrailslog)
这个东东非常强大,可以分析Rails, Merb, Nginx, Apache, MySQL, postgres, 等各种日志。  ( it supports many formats of logs , including: mysql, postgres, apache .nginx ... ) $ gem install request-log-analyzer ...