1. 看日志。  1.1 日志的格式很重要,务必要有时间戳。有exception traceback, 有 Completed 时间1.2 rails log跟 stdout put 有时候会分别写到两个不同的文件当中。 如果rails log 没有信息,那么就要看 stdoutput 的信息(如果你用的是thin服务器的话,就要看 thin.yml 中的配置了)  我们...
使用goaccess分析nginx日志(analyzenginxlogusinggoaccess)
nginx 日志无法用rails-request-analyzer 来分析。 需要使用 goaccess 。 因为前者一分析就死机,后者速度更快,分析1.2G的日志大约20秒。 ( if you want to analyze nginx log, use GoAccess) 安装: $ aptitude install goaccess 用法非常简单:  (quite simpl...
使用god+delayed_job是,不要使用god的keep_alive选项(don'tusegod'skeepaliveoptionwhenusinggodcontrollingdelayed_jobs)
因为delayed_job有休眠时间。god会不断的唤醒它。。 God is always trying to start delayed_job every 5 seconds by default: God's log file: 23 ERROR: there is already one or more instance(s) of the program running ...
Rails Rspec 在rails项目中增加rspec(addrspectorailsandtestlibfiles)
1. add to Gemfile: # Gemfile: gem 'rspec-rails', '~> 3.0.0' 然后运行: $ bundle exec rails generate rspec:install 记得要把生成的.rspec 文件做个修改,删掉 # .rspec file: --color # NO --warning, --require spec_hel...
设置rails使用中国大陆时间(setrailsusingbeijingtime)
insert “ config.time_zone = ‘Asia/Harbin’” into your config/application.rb # config/application.rb module MCacheCleaner class Application < Rails::Application config.time_zone = 'Asia/...
使用nginx+thin的配置启动railsserver.(usingnginx+thintoserverailsapp)
1. nginx 中做如下配置: server { listen 80; charset utf-8; location / { proxy_pass http://rails_servers; proxy_redirect default; ...
Rails Jquery中的callback(callbackinrails Jquery(ujs))
如下: (refer to : http://stackoverflow.com/questions/13224482/rails-confirm-modifier-callback ) <%= coffee_script_tag do %> $(document).on 'confirm:complete', (e, answer) -> if(an...
Nginxrewritetry_filetips(nginxrewritetry_files小提示)
refer to: http://stackoverflow.com/questions/22032751/how-to-process-dynamic-urls-as-static-pages-using-nginx 最近,一个项目的请求让我们的Rails不足以负担(300 req /seconds是我们的极限),所以我打算把它做成静态化的页面,这样在我的 2核CPU上都可以轻松跑到15...
Rails部署时gemfile相关的内容(gemfilesrelatedstuffwhendeployingrailsapptoproduction)
1. 最好指定好具体的版本, .e.g:  (give the explicit version )  source 'http://ruby.taobao.org' gem 'rails', '4.0.0' gem 'uglifier', '2.4.0' gem 'coffee-rails', '4.0.1' 2. $ bundle package --all 3....
接口系统对于异常的处理(exceptionsinwebinterfacedesign)
目前对于异常有两种处理: (there're 2 ways for exception process )  1. 不处理。 直接抛出。让客户能看到,方便开发人员的处理。 典型的是使用exception_notification 这样的插件, 遇到异常,直接给开发人员邮件。  ( just throw it so that developers could find wh...
Rubyonrails是web开发王道啊亲!
22分钟从0 搭建环境, 写出一个假接口, 调通前端后端,再来16 分钟使用真实数据 + 润色。 换另外一个语言试试。。。。 精锐游击队一样干掉 战五渣 正规军
动态web页面的速度跟nginx服务下的静态页面的支持速度,天壤之别啊。(dynamicpagesissoslowcomparingtostaticpagesservedbynginx)
今天心血来潮,比较了一下静态服务器和动态WEB服务器,在同样并发下的相应速度。 前者是后者速度的50倍。 在我的机器上轻松支撑到 15K req/s, 而 使用了cache的 rails : 300 req/s. 哎。。。 (in short: nginx serving static page is 50 faster then rails server using cache) th...
Markdown的语法(markdowngrammar)
refer to : http://guides.github.com/overviews/mastering-markdown/ and https://help.github.com/articles/github-flavored-markdown ruby code: ```ruby require 'redcarpet' markdown = Redcarpet.new("He...
Copyallfilesfromgemfoldertorailsfolder
$ cd <gem_folder> $ cp -r app config lib <rails_folder> 不过这个方法不够好,因为 script 目录下的文件容易被覆盖 ( local.yml, routes.rb 等) ,最好的办法还是让这个 gem 单独写个rake 任务,(例如: rake your_gem:override )  ( the b...
在rails中使用cas客户端(casclientforrails)
Ruby 客户端 使用方法0. 在 Gemfile中,加入: gem 'rubycas-client', :git => 'git://github.com/rubycas/rubycas-client.git'     (要用这个版本,否则 会出现undefine method before ...)  然后 $sudo bundle 注意: 不要使用 ...
Selectingawebhost(如何选择主机,主机空间,webhost)
refer to http://stackoverflow.com/questions/2339324/selecting-a-rails-host/21640941#21640941 简言之, 忘记heroku, 尽情的使用linode吧, 260块钱一个月,2G内存, 用起来跟独立的机器一样。 而HEROKU把太多LINUX 的功能抽取出了service, 用起来不方便,而且一旦脱离了...
Bulkinsertdeleteinrails34(rails34中的批量删除)
批量删除: (bulk delete)  # if a plan has 100K target_urls: (如果一个plan 有 100K 个 target_urls ) # never use: (绝对不要这样做) #@plan.target_urls.clear # you should use: TargetUrl.delete_all(:plan_id =...
Installrefinery_cmsusingmysql
refinery_cms is not bad. I have been using it for my personal website(siwei.me, aka shensiwei.com), its default database is sqlite3. this guide will show you how to install it under mysql. step1. $...
Tinymce Anothergoodwysiwygeditor(rails中使用tinymce)
在rails 中的使用方式: 建议使用 gem 来做。否则一点儿一点儿的copy assets ,很麻烦。(it's strongly recommended we use the gem instead of adding files to app/assets image/stylesheets manually. see: https://github.com/spohlenz/ti...
Rails3.0压缩javascript和css(compresscssjsinrails3.0 )
压缩 javascript 和 css  参考 (refer to ): http://stackoverflow.com/questions/7112218/how-to-install-a-plugin-in-rails-3-getting-a-commands-is-not-a-module-typeerro/23507780#23507780 1. 编辑 Rakefil...