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 101£º¶ÔÏóºÍ·½·¨
Written by Allen Lee
´Ó¾²Ì¬·½·¨ËµÆð
ÔÚÉÏһƪÎÄÕÂĩ⣬ÎÒÃÇÌáµ½ÁËÊܱ£»¤µÄ¾²Ì¬·½·¨……Êܱ£»¤µÄ¾²Ì¬·½·¨£¿£¿RubyµÄprotected²»ÊÇÓÃÀ´ÏòÏàͬÀàÐ͵IJ»Í¬ÊµÀý¿ª·ÅÊÜÏÞ·½·¨µÄ·ÃÎʵÄÂð£¨Íü¼ÇprotectedµÄÓ÷¨ÁË£¿²»Òª½ô£¬»ØÈ¥ÉÏһƪÎÄÕ¸´Ï°Ò»Ï°ɡ££© ......
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) ......
ÉÏÉÏÖÜÔÚÊéµê¿´µ½Ò»±¾¡¶Ruby
Éè¼Æģʽ¡·£¬¼ñÆðÀ´ 10 ·ÖÖÓ¿´Í꣬ÈÓÁË£¨±ðÎÊÎÒΪʲô……£©
ÏÂÃæÓÃ Ruby
ддÉè¼Æģʽ£¬Ë³±ãÅúÒ»Åú Java ºÍ Gof
¡£
1.Factory
ºÍ Abstract Factory
class
Factory
attr_accessor :product
......
SleekEngine
Ëæ׿ÆËã»úÓ²¼þµÄ¿ìËÙ·¢Õ¹£¬10ÄêÇ°ÒòΪËÙ¶ÈÎÊÌâ¶ø±»Ú¸²¡µÄJavaÏÖÔÚ³ÉÁ˼ÆËã»úÁ÷ÑÔÓïÑÔÖеÄÀϴ󣬵«ÊÇËüÈ´ÈÔ±»ÈÏΪ¸´ÔÓ±¿ÖØ£¬½ü¼¸ÄêÀ´¶¯Ì¬Óï
ÑÔÈ´ÓкóÀ´¸ÏÉϵÄÇ÷ÊÆ£¬ÕÆÎÕÒ»ÃŶ¯Ì¬ÓïÑÔ³ÉÁ˳ÌÐòÔ±ÐèÒª¿¼ÂǵÄÊÂÒË¡£ ½üÆÚ½Ó´¥Á˼¸ÖÖÁ÷ÐеĶ¯Ì¬ÓïÑÔPython, Ruby,
Groovy£¬ËüÃÇÏà±È¾²Ì¬ÓïÑÔJava/C++À´Ëµ£¬´óÎ ......
ÉÏһƪÎÄÕÂ
˵ÁËRubyµÄ°²×°ºÍÔËÐУ¬Ò²¼òµ¥µÄ˵ÁËÏÂÀàºÍ¶ÔÏó¡£ÕâÀïÖ÷Ҫ̸̸±äÁ¿µÄÎÊÌâ¡£
ÏÈ˵³£Á¿
¡£Èç¹û±äÁ¿ÃûÒÔ´óд×Öĸ¿ªÍ·£¬¾Í±»ÊÓΪ³£Á¿£¬µ«Í¨³£ÊÇËùÓÐ×Öĸ¶¼´óд¡£µ«ºÍÆäËûÓïÑÔ²»Í¬£¬ÔÚRubyÖУ¬ÄãÈÔÈ»¿ÉÒԸı䳣Á¿µÄÖµ£¬µ±È»½âÊÍÆ÷»áÅ׳öÒ»¸ö¾¯¸æ£º
#! /usr/bin/ruby
CONSTANT = 1
print "#{CONSTANT}\n&qu ......