- 浏览: 132093 次
- 性别:
- 来自: 深圳
-
最新评论
-
kqy929:
最近我也在使用spree-0.9.4,准备改定下。但发现,性能 ...
rails plugins 做一个电子商务系统 -
山雨欲来风满楼:
ruby的这个程序没有时间戳,好像 logger都没有时间戳, ...
logger (ruby) -
dazuiba:
很不可思议,照常理,这个是一个很常见的应用场景,为什么EXTJ ...
combo values in Editor Grid Panels combo值显示问题 -
xu_ch:
有没有helper?
(ruby)String Extensions(字符串、首字母大写,复数单数转换) -
panboxian_2008:
class Publisher(models.Model):
...
ruby 语言 手记
文章列表
转自:http://fanqiang.chinaunix.net/program/code/2006-06-27/4695.shtml
删除 core 文件
# find ~ -name core -exec file {} \; -exec rm -i {} \;
查看使用文件的进程
# fuser -u /usr/my_application/foo
搜索字符串
#grep "hello world" `find ./ -name "*" -print -exec file {} \; |grep text | cut ...
- 2008-08-19 11:54
- 浏览 2120
- 评论(1)
Encapsulates the common pattern of:
alias_method :foo_without_feature, :foo
alias_method :foo, :foo_with_feature
With this, you simply do:
alias_method_chain :foo, :feature
替我们定义了两个方法:foo_with_feature 和 foo_without_feature <保存原来的foo方法>
def foo_with_feature
在此添加想向foo方法里面写的代码
foo_wi ...
- 2008-07-01 18:03
- 浏览 3255
- 评论(0)
javascript Math参考
Math Object Methods
FF: Firefox, N: Netscape, IE: Internet Explorer
Method Description FF N IE
abs(x) Returns the absolute value of a number 1 2 3
acos(x) Returns the arccosine of a number 1 2 3
asin(x) Returns the arcsine of a number 1 2 3
atan(x) Retu ...
- 2008-06-29 20:43
- 浏览 1050
- 评论(0)
1. 拷贝redcloth.rb到ror的lib目录内。
2. 拷贝jstoolbar相关的javascript 、stylesheet、images到对应的public目录里面。另外把压缩包里的help目录完整地拷贝到public目录下,其是redcloth语法的使用帮助.
3. 在application的helper方法中添加如下两个方法:
require 'redcloth' #在application_helper 文件头引入redcloth
用于页中生成相应textarea框的jstoolbar方法。
def wikitoolbar_fo ...
- 2008-06-27 22:45
- 浏览 1797
- 评论(0)
# ==== Relying on named routes
#
# If you instead of a hash pass a record (like an Active Record or Active Resource) as the options parameter,
# you'll trigger the named route for that record. The lookup will happen on the name of the class. So passing
# a Workshop ...
- 2008-06-26 11:55
- 浏览 1645
- 评论(0)
difference = Time.now - time
seconds = difference % 60
difference = (difference - seconds) / 60
minutes = difference % 60
difference = (difference - minutes) / 60
hours = difference % 24
difference = (difference - hours) / 24
days = differen ...
- 2008-06-25 12:38
- 浏览 1783
- 评论(0)
使用include中嵌Hash取出一个多层次的对象关联数据.
首先有如下关系:
project issue : 一对多
issue comment : 一对多
comment history : 一对多
Project [1] <---- [n] issue (1) <---- (n) comment [1] <---- [n] history
class Project
has_many :issues
end
class Issue
belongs_to :project
has_many :cccc # cc ...
- 2008-05-22 16:09
- 浏览 1151
- 评论(0)
在改AJAXRequest的过程中,碰到了个问题,应该算是Firefox和IE之间的兼容性问题。
提交表单时,往往需要先对表单进行验证,而这个验证的过程一般是放在form标签的onsubmit属性中。
onsubmit一般是由浏览器在form的submit动作发生时自动触发,但是如果表单由我们自己来提交,比如在AJAX应用中,就是由我们自己写程序将表单转换成请求字符串,再通过XMLHttpRequest发送到服务器,那么如果在此同时不丢掉表单验证的话,就需要我们自己来获取 onsubmit属性,并去处理它。
在获取属性时,为了保证兼容性,我用getAttribute来获取标签的属性值,但是 ...
- 2008-04-24 17:29
- 浏览 3891
- 评论(1)
Sku MODEL :
class Sku < ActiveRecord::Base
has_and_belongs_to_many :records,
:delete_sql=>'DELETE FROM skus_records WHERE sku_id= \'#{id}\' AND record_id = #{record.id}',
:before_remove=>:record_removed_info,
:insert_sql =>'insert into skus_records (sku_id,reco ...
- 2008-04-22 10:16
- 浏览 1207
- 评论(0)
http://ap4r.rubyforge.org/wiki/wiki.pl?GettingStarted
1. Business logics can be implemented as simple Web applications, or ruby code, whether it's called asynchronously or synchronously.
2. Asynchronous messaging is reliable by RDBMS persistence (now MySQL only) or file persistence, under th ...
- 2008-04-09 16:59
- 浏览 1061
- 评论(0)
使用的是一个一对多关联,代码如下:view: partial
名称:<input type="text" name="invoice[][name]" />
描述:<input type="text" name="invoice[][description]" /><br/>
rhtml:
<% form_tag "/purchase/save_order" do -%>
<p><label for="order_nam ...
- 2008-04-07 21:34
- 浏览 2603
- 评论(0)
情景:
在使用 rail 中的 自动完成功能 auto_complete_field时,假若返回的页面中有 javascript脚本,那它将不会被返回。 必需把它用 javascript_function 方法进行改写。
a.rhtml 中 render _b.rhtml 页面。 在_b.rhtml中如果包含了 javascript脚本,则不能被render到a.rhtml中。
我在_b.rhtml中用了auto_complete_field来对用户输入进去提示。因为auto_complete_result 返回的已经是javascript脚本了,就不能把javascript发送 ...
- 2008-04-03 17:18
- 浏览 3914
- 评论(0)
mysql进行优化的地方,简单总结几点:
在设计数据表的时候,尽可能使用最有效(最小的)数据类型,尽可能使用更小的整数类型,可能定义字段类型为 NOT NULL。这会运行的更快,而且每个字段都会节省1个bit。如果在应用程序中确实需要用到 NULL,那么就明确的指定它。不过要避免所有的字段默认值是 NULL),尽可能使用最有效(最小的)数据类型。MySQL有好几种特定的类型能节省磁盘和内存。 尽可能使用更小的整数类型。在 MyISAM 表中,如果没有用到任何变长字段(VARCHAR, TEXT, 或 BLOB字段)的话,那么就采用固定大小的记录格式。这样速度更快,不过可能会浪费点空间。表的主索引 ...
- 2008-04-02 17:57
- 浏览 1018
- 评论(4)
第四章 说服有抵触情绪的人
无论是什么原因使您做出决定,都永远会有人说您错了。也总会有困难让您相信批评您的人是正确的。
制订一条行动路线,沿着它坚持走下去,是需要具有与士兵一样的勇气的。
---------Ralph Waldo Emerson
4.1. 抵制主要来自两方面:经理和开发人员。
经理和开发人员经常会因为骄傲而成为其牺牲品。这两种人都惧怕变化,不愿承认他们需要学习新的知识。这是来自这一群人的诸多抵触情绪中最关键的部分。您会遇到的抵制远不像这些这么简单,而且也并不是一开始就全部暴露的。您要有思想准备,随时都应准备处理这类问题。
4.2. 有说服力的结果
如果XP ...
- 2008-04-01 22:58
- 浏览 842
- 评论(0)
MySql的字符串函数
ASCII(str)
返回字符串str的最左面字符的ASCII代码值。如果str是空字符串,返回0。如果str是NULL,返回NULL。
mysql> select ASCII('2');
-> 50
mysql> select ASCII(2);
-> 50
mysql> select ASCII('dx');
-> 100
也可参见ORD()函数。
ORD(str)
...
- 2008-03-27 17:52
- 浏览 2777
- 评论(0)