2008-07-01

rails魔术字段的实现 ,alias_method_chain用法

关键字: rails, alias_method_chain
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 ...
2008-06-29

javascript Math reference

关键字: javascript math参考
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 ...
2008-06-26

rails route

关键字: url_for与路由
# ==== 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 ...
2008-06-25

ruby 日期

关键字: ruby time
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 ...
2008-05-22

使用include中嵌Hash取出一个多层次的对象关联数据

关键字: ruby ror model active_record
使用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来获取标签的属性值,但 ...
2008-04-22

多对多关联数据存储ROR

关键字: ror 多对多关联保存 删除
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 ...
2008-04-09

HowToRunBackgroundJobsInRails--ap4r

关键字: ap4r ror ruby backgroundjobs rails 定期任务
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>物 品 ...
xu_wccq
搜索本博客
我的相册
Ac7ad940-edbc-3b23-8443-5fe2ea338061-thumb
productcenter.bmp
共 2 张
最近加入圈子
存档
最新评论