易截截图软件、单文件、免安装、纯绿色、仅160KB

ruby on rails(10) 处理订单

订单处置,首先要有一个订单的详细列表(包括数量,价钱啥的)和一个对于个人的一些信息的一个表。因而我们创造两个模型,line_item(列表项),order(列表),其后编者如次
/db/migrate xxx_create_order xxx_line_item
Ruby代码
一.class CreateOrders < ActiveRecord::Migration
二.def self.up
3. create_table :orders do |t|
4. t.string :name
5. t.text :address
6. t.string :email
7. t.string :pay_type, :limit => 十
8. t.timestamps
9. end
十.end
11.
12.def self.down
13. drop_table :orders
14.end
15.d
class CreateOrders < ActiveRecord::Migration
def self.up
create_table :orders do |t|
t.string :name
t.text :address
t.string :email
t.string :pay_type, :limit => 十
t.timestamps
end
end
def self.down
drop_table :orders
end
end
Ruby代码
1. class CreateLineItems < ActiveRecord::Migration
二.def self.up
3. create_table :line_items do |t|
4. t.integer :product_id, :null => false,:options =>
5. "CONSTRAINT fk_line_items_products REFERENCES products(id)"
6. t.integer :order_id,:null => false, :options =>
7. "CONSTRAINT fk_line_items_orders ReEFERENCES orders(id)"
8. t.integer :quantity, :null => false
9. t.decimal :total_price, :null => false,:precision => 八,:scale => 二
10. t.timestamps
11. end
12.end
13.
14.def self.down
15. drop_table :line_items
16.end
17.d
class CreateLineItems < ActiveRecord::Migration
def self.up
create_table :line_items do |t|
t.integer :product_id, :null => false,:options =>
"CONSTRAINT fk_line_items_products REFERENCES products(id)"
t.integer :order_id,:null => false, :options =>
"CONSTRAINT fk_line_items_orders ReEFERENCES orders(id)"
t.integer :quantity, :null => false
t.decimal :total_price, :null => false,:precision => 八,:scale => 二
t.timestamps
end
end
def self.down
drop_table :line_items
end
end
t.integer :product_id, :null => false,:options =>
"CONSTRAINT fk_line_items_products REFERENCES p


相关文档:

ruby调用DLL

 开源测试工具watir是采用的ruby语言进行开发的。在研究watir框架的时候,发现有一部分函数watir没有提供而且暂时没找到合适的gem包,而很多功能在我们原来的自动化测试框架中都通过c写的dll进行了实现,于是我们希望能够把这部分的dll无缝的移植到watir上,减少我们的工作量,而且可以更高效的实现我们需要的功能。
......

清楚VSS文件的批处理(Ruby版)

 
def delVss(path)
  if File.directory?(path)
    for f in d = Dir.open(path)
        fpath = File.join(path, f) 
      if(f!="."&&f!="..")      
    ......

ruby xml excel

require 'win32ole'
fns = Dir.glob("*.xls")
application = WIN32OLE.new("excel.application") 
application.visible = TRUE
f = File.new('errorCauseEN.xml','w')
f.puts('<?xml version="1.0" encoding="utf-8"?>')
f.puts('<!-- edited with XMLSPY v5 U (http://www.xmlspy.com) by et8 (et8) ......

ubuntu下搭建ruby on rails

 一 安装ruby
$sudo apt-get install ruby irb rdoc
二 安装gem
1.到这里下载 ,最好是最新版本,我的1.3.5
解压,切换到当前目录,执行$sudo ruby setup.rb
或者这样:
$ tar xzvf rubygems-1.3.5.tgz   (解压)
$ cd rubygems-1.3.5     (切换到此目录)
$ sudo ruby setup ......

用 Ruby 踩踩四人帮




上上周在书店看到一本《Ruby
设计模式》,捡起来 10 分钟看完,扔了(别问我为什么……)
下面用 Ruby
写写设计模式,顺便批一批 Java 和 Gof

1.Factory
和 Abstract Factory
class
 Factory  
  attr_accessor :product
   ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号