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_with ...
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) Ret ...
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_f ...
# ==== 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 Worksho ...
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 = differe ...
使用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 # c ...
在改AJAXRequest的过程中,碰到了个问题,应该算是Firefox和IE之间的兼容性问题。
提交表单时,往往需要先对表单进行验证,而这个验证的过程一般是放在form标签的onsubmit属性中。
onsubmit一般是由浏览器在form的submit动作发生时自动触发,但是如果表单由我们自己来提交,比如在AJAX应用中,就是由我们自己写程序将表单转换成请求字符串,再通过XMLHttpRequest发送到服务器,那么如果在此同时不丢掉表单验证的话,就需要我们自己来获取 onsubmit属性,并去处理它。
在获取属性时,为了保证兼容性,我用getAttribute来获取标签的属性值,但 ...
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,record_id,cr ...
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 t ...
使用的是一个一对多关联,代码如下: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_name">订单:</label><%= text_field :order, :name %></p>
<p>物 品 ...







评论排行榜