首先,要明白这几个ruby的原理1、默认(包括你所用的定义方法)在顶层定义的都是private的实例方法2、private方法是不允许指明接收者的,其接收者只能是隐含的selfdef x11puts "in x11"enddef x11=(t) puts tend
x11self.x11="ddd"当前定义了两个方法,都是private的,可以puts self.private_methods.sort 看到那为什么 x11可执行,self.x11不能执行了? 上面已有解释,调用对象所属类的实例方法是不能加self的,因为,ruby中的private很微秒,它与java等都不同。它 ...
- 15:34
- 浏览 (18)
- 评论 (0)
- 分类: rubyonrails
运行时提示已active0.4.5.不能active1.0.0,那直接删除0.4.5的gem就行了。
- 17:38
- 浏览 (30)
- 评论 (0)
- 分类: rubyonrails
转道友Blog中的一小段code说明ruby中的闭包
procs = []
(1..3).each do |i|
procs << lambda { puts i }
end
procs.each { |p| p.call }
# Output:
# 1
# 2
# 3
###############################################
procs = []
for j in (1..3) do
procs << la ...
- 08:01
- 浏览 (37)
- 评论 (0)
- 分类: rubyonrails
def trc_utf8(text, length = 40, t_string = "...")
l=0
char_array=text.unpack("U*")
char_array.each_with_index do |c,i|
  ...
- 21:45
- 浏览 (42)
- 评论 (0)
- 分类: rubyonrails
TCMalloc(Thread-Caching Malloc)是google开发的开源工具──“google-perftools”中的成员。与标准的glibc库的malloc相比,TCMalloc在内存的分配上效率和速度要高得多,可以在很大程度上提高MySQL服务器在高并发情况下的性能,降低系统负载。 TCMalloc的实现原理和测试报告请见一篇文章:《TCMalloc:线程缓存的Malloc》 为MySQL添加TCMalloc库的安装步骤(Linux环境): 1、64位操作系统请先安装libunwind库,32位操作系统不要安装。libunwind库为基于64 ...
- 09:15
- 浏览 (47)
- 评论 (0)
require 'net/http'require 'uri'module Net class HTTP def HTTP.get_with_headers(uri,headers=nil) uri=URI.parse(uri) if uri.respond_to? :to_str start(uri.host,uri.port) do |http| &nbs ...
- 19:42
- 浏览 (59)
- 评论 (0)
- 分类: rubyonrails
用ruby写个网页抓取的小东东,遇到问题:
环境:ubuntu8.04+netbeans6.1+ruby1.8.6
在ruby中使用Net::HTTP.get_response抓取一个GB2312编码的网页后转换成utf8全是乱码,主要代码部分如下
resp=Net::HTTP.get_response(URL,URI)
body=resp.body[0,resp.size-1]
r=Iconv.iconv("UTF-8//IGNORE","GB2312//IGNORE",body)
接下来我要使用r中的内容
但是发现里面的内容全是乱码,直接写入数据库写不进去,提 ...
== Installation<tt>./script/plugin install http://code.dunae.ca/acts_as_slugable</tt>== Usage examplesIn your target table, add a column to hold the URL slug.=== With scope class Page < ActiveRecord::Base acts_as_slugable :source_column => :title, :target_co ...
- 09:29
- 浏览 (61)
- 评论 (0)
- 分类: rubyonrails
http://www.codyfauser.com/2008/1/17/paypal-express-payments-with-activemerchant
- 18:18
- 浏览 (55)
- 评论 (0)
- 分类: rubyonrails
- 浏览: 19212 次
- 性别:

- 来自: 南京

- 详细资料
搜索本博客
最新评论
-
ferret+acts_as_ferret+RM ...
rmmseg作者是浙大的pluskid
-- by leondu -
全国省市县三级数据库
个如果第三vs
-- by xuchunming -
activescaffold插件的基本 ...
这个文章里有用到select:http://www.ibm.com/develo ...
-- by yangr -
activescaffold插件的基本 ...
我也在找如何生成select的方法!
-- by yangr -
ubuntu下使用capistrano时 ...
$ sudo apt-get install libopenssl-ruby1. ...
-- by iceskysl






评论排行榜