Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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(Ê®¶þ):RubyÀà

Ò»¡¢ÀàµÄ¶¨Òå¡¢ÀàµÄʵÀý·½·¨ ¶þ¡¢Ìض¨¶ÔÏóµÄ·½·¨ ÔÚRubyÀÎÒÃÇ¿ÉÒÔΪһ¸ö¶ÔÏ󵥶À¶¨Òå·½·¨ Èý¡¢Öض¨Òå·½·¨ ´ÓÏÂÃæ´úÂë¿ÉÒÔ¿´³ö£¬ºóÃæµÄ¶¨Òå»á¸²¸ÇÇ°ÃæµÄ¶¨Òå ËÄ¡¢ÖØдò¿ªÀà RubyÀïÎÒÃÇ¿ÉÒÔÔÙ´ò¿ªÒ»¸öÀ࣬ÏòÕâÀàÌí¼Ó·½·¨£¬ÓеãÏñC#ÀïµÄ·Ö²¿À࣬µ«²»ÓüÓÌرð±ê¼Ç. ÎÒÃÇÒ»°ã²»Òª²ð¿ªÀàµÄ¶¨Ò壬ÒòΪÄÇÑù²»ºÃÀí½ ......

rubyµ÷ÓÃDLL

 ¿ªÔ´²âÊÔ¹¤¾ßwatirÊDzÉÓõÄrubyÓïÑÔ½øÐпª·¢µÄ¡£ÔÚÑо¿watir¿ò¼ÜµÄʱºò£¬·¢ÏÖÓÐÒ»²¿·Öº¯ÊýwatirûÓÐÌṩ¶øÇÒÔÝʱûÕÒµ½ºÏÊʵÄgem°ü£¬¶øºÜ¶à¹¦ÄÜÔÚÎÒÃÇÔ­À´µÄ×Ô¶¯»¯²âÊÔ¿ò¼ÜÖж¼Í¨¹ýcдµÄdll½øÐÐÁËʵÏÖ£¬ÓÚÊÇÎÒÃÇÏ£ÍûÄܹ»°ÑÕⲿ·ÖµÄdllÎÞ·ìµÄÒÆÖ²µ½watirÉÏ£¬¼õÉÙÎÒÃǵŤ×÷Á¿£¬¶øÇÒ¿ÉÒÔ¸ü¸ßЧµÄʵÏÖÎÒÃÇÐèÒªµÄ¹¦ÄÜ¡£
......

Ruby 101£º¶ÔÏóºÍ·½·¨


Ruby 101£º¶ÔÏóºÍ·½·¨
Written by Allen Lee
´Ó¾²Ì¬·½·¨ËµÆð
      ÔÚÉÏһƪÎÄÕÂĩ⣬ÎÒÃÇÌáµ½ÁËÊܱ£»¤µÄ¾²Ì¬·½·¨……Êܱ£»¤µÄ¾²Ì¬·½·¨£¿£¿RubyµÄprotected²»ÊÇÓÃÀ´ÏòÏàͬÀàÐ͵IJ»Í¬ÊµÀý¿ª·ÅÊÜÏÞ·½·¨µÄ·ÃÎʵÄÂð£¨Íü¼ÇprotectedµÄÓ÷¨ÁË£¿²»Òª½ô£¬»ØÈ¥ÉÏһƪÎÄÕ¸´Ï°Ò»Ï°ɡ££© ......

rubyÎļþ²Ù×÷

1¡¢ÎļþµÄ´ò¿ªÓë¹Ø±Õ
    ``r'' Read-only, starts at beginning of file (default mode).
    ``r+'' Read-write, starts at beginning of file.
    ``w'' Write-only, truncates existing file to zero length or creates a new file for writing. ......

win»·¾³Ï±¾µØ°²×°ruby on rails

¹ý³ÌÈçÏ£º
1¡¢rubyÏÂÔØÒ»¼ü°²×°£º
http://rubyforge.org/frs/download.php/29263/ruby186-26.exe
ruby -v ÏÔʾ°æ±¾£¬°²×°³É¹¦
2¡¢ÏÂÔØrubygems°²×°£º
http://rubyforge.org/frs/download.php/60719/rubygems-1.3.5.zip
½âѹ£¬ruby setup.rb
gem -v  ÏÔʾ°æ±¾£¬°²×°³É¹¦
3¡¢ÏÂÔØrailsµÄ gem °²×°£¨gem install ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ