
ruby on rails
yxw2014
这个作者很懒,什么都没留下…
展开
-
Unicorn vs thin
http://ihower.tw/rails3/deployment.html Ruby on Rails 實戰聖經 網站佈署http://ruby-china.org/topics/35 Ruby-China.org 选择用 Thin 还是 Unicorn?Unicorn http://unicorn.bogomips.org/ (Multi-processed 模型原创 2014-03-29 18:11:56 · 1439 阅读 · 1 评论 -
Ruby on Rails环境中的异步编程
一个老项目中用的还是ruby 1.8.7, 非常老的版本, 用不到coroutine等比较新的技术, 所以在项目中做一些异步的事情非常困难。当然了, 如果是最新版本的ruby,这些不是问题。ruby 1.8.7环境下要执行异步任务, 有2种方式, 这里只是简单记一下, 没有任何技术含量。1. delayed job, 用的github上的开源项目, https://github.c原创 2016-01-08 15:04:33 · 2142 阅读 · 0 评论 -
ruby的一些特性汇总
在Ruby中有很多方法是以?和!号结尾的 “?”被用于标示谓词,即返回Boolean直的方法,如Array.empty?(判断数组中元素是否为空) “!”出现在方法名尾部的感叹号表明使用该方法是需要多加小心。许多Ruby的核心类都定义了 成对的方法,它们具有同样的名称,只是结尾相差一个“!”,通常情况下,不带感叹号的方法返 调用该方法的一个拷贝,二带感叹号的方法则是一个可变方法,该方法会修原创 2014-04-01 23:18:02 · 1368 阅读 · 1 评论 -
Ruby On Rails 环境中集成Slack
记录一下, 直接上代码:相关API文档:https://api.slack.com/ def self.add_ann(group, user, title, url, desc, slack_info_id= nil, color= '#ffba01') team_url= $HOST + "/team/#{group.g_name}" title= title原创 2015-12-25 15:46:18 · 770 阅读 · 0 评论 -
Using Arel to Compose SQL Queries
https://robots.thoughtbot.com/using-arel-to-compose-sql-queriesThe Arel::Table object acts like a hash which contains each column on thetable. The columns given by Arel are a type ofNode, whic原创 2015-10-21 09:39:08 · 518 阅读 · 0 评论 -
Rails, ActiveRecord::Base.include_root_in_json
在rails 中object to_json 之后是有问题的。解决办法有两种:1. ActiveRecord::Base.include_root_in_json = false这个设置是全局的,影响很大。2. 写一个通用的犯法处理数据. def obj_to_hash(obj) if obj.class.to_s == 'Array' h = []原创 2015-09-10 15:57:33 · 723 阅读 · 0 评论 -
ruby thin的配置
address: 0.0.0.0pid: /var/www/website/current/tmp/pids/unicorn.pidgroup: wwwport: 2101timeout: 30log: log/thin.logmax_conns: 1024require: []max_persistent_conns: 512environment:原创 2015-05-27 15:01:13 · 1398 阅读 · 0 评论 -
rvm
#!/usr/bin/env bash# modify the ruby string belowruby_string="ruby-1.8.7-p374@daemon"true ${rvm_path:="/usr/local/rvm"}if [[ -s "$rvm_path/scripts/rvm" ]] ; then source "$rvm_pa原创 2015-05-27 11:20:02 · 710 阅读 · 0 评论 -
ocra 打包ruby应用
ocra blog/script/rails blog --output blog.exe --add-all-core --gemfile blog/Gemfile --no-dep-run --gem-full --chdir-first --dll libmysql.dll --dll zlib1.dll --dll ssleay32.dll --dll libyaml-0-2.dll -原创 2014-06-11 21:26:37 · 2154 阅读 · 0 评论 -
Ruby on Rails 项目里面字符串过滤html标签
Ruby on Rails 项目里面字符串去掉html标签没有特别直接的办法, 需要借助第三方lib:1 . 比较简单的方式, 不支持换行:require 'nokogiri'item = Nokogiri::HTML('<a href="#">string</a>')puts item.to_html2. 第二种, 代码来自Github, 稍作修改:requ...原创 2015-12-25 15:37:14 · 2021 阅读 · 0 评论