Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Rubyʵ¼ù—HelloWorld

¿ª·¢»·¾³
OS£ºWindowsXP
Ruby: Ruby1.9.1
Rails: Rails2.3.5
IDE: RubyMine2.0.1
1¡¢´´½¨Rails¹¤³Ì
2¡¢ÐÞ¸Ä /config/database.yml
×Ô¶¯´´½¨µÄ¹¤³ÌÖÐĬÈÏÊý¾Ý¿âÁ¬½ÓµÄÊÇsqlite£¬Èç¹ûûÓа²×°´ËÊý¾Ý¿â£¬ÐèÒªÐ޸ĸÃÅäÖ㨱¾ÀýÖÐʹÓõÄÊÇmysql£©
# Mysql Version 5.1.46
development:
adapter: mysql
database: test
username: root
password: root
host: localhost
3¡¢´´½¨Controller
ÔÚapp/controllerÖд´½¨say_controller.rb
´´½¨Íê³Éºó£¬ÔÚ¿ØÖÆ̨ÐÅÏ¢Öн«ÏÔʾ´Ë¹ý³Ì´´½¨µÄһϵÁÐÎļþ
C:\Ruby19\bin\ruby.exe -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) E:/Ruby/HelloWorld/script/generate controller -s say
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/say
      exists  test/functional/
      create  test/unit/helpers/
      create  app/controllers/say_controller.rb
      create  test/functional/say_controller_test.rb
      create  app/helpers/say_helper.rb
      create  test/unit/helpers/say_helper_test.rb
Process finished with exit code 0
4¡¢ÐÞ¸Äsay_controller.rb
½«ÄÚÈÝÐÞ¸ÄÈçÏ£º
class SayController < ApplicationController
def hello
end
end
5¡¢´´½¨hello.rhtml.erb
ÔÚapp/views/say Ŀ¼Ï´´½¨hello.rhtml.erb
ÐÞ¸ÄÆäÖеÄÄÚÈÝÈçÏ£º
<html>
<head>
<title>Hello, Rails!</title>
</head>
<body>
<h1>Hello from Rails!</h1>
</body>
</html>
6¡¢ÐÞ¸Äroutes.rb
ÐÞ¸Äconfig/routes.rb£¬ÉèÖÃеÄÓ³Éä¹æÔò
#·ÓÉÉèÖã¬/say/HelloÊǵØÖ·ÉèÖã»controllerÊǶÔÓ¦µÄcontrollersĿ¼ÏµÄÀ࣬actionÖ¸controllerÖж¨ÒåµÄ·½·¨£¬Çø±ð´óСд
map.connect '/say/Hello',:controller=>"say",:action=>"hello"
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
Æô¶¯·þÎñRails·þÎñÆ


Ïà¹ØÎĵµ£º

ruby on rails


rubygems
Ruby on Rails ÊÇÒ»¸ö¿ÉÒÔʹÄ㿪·¢£¬²¿Êð£¬Î¬»¤ web Ó¦ÓóÌÐò±äµÃ¼òµ¥µÄ¿ò¼Ü¡£
¡¡¡¡RubyµÄ×÷ÕßÓÚ1993Äê2ÔÂ24ÈÕ¿ªÊ¼±àдRuby£¬Ö±ÖÁ1995Äê12Ô²ÅÕýʽ¹«¿ª·¢²¼ÓÚfj£¨ÐÂÎÅ×飩¡£Ö®ËùÒÔ³ÆΪRuby£¬ÊÇÒòΪPerlµÄ·¢ÒôÓë6Ôµĵ®Éúʯpearl£¨ÕäÖ飩Ïàͬ£¬Òò´ËRubyÒÔ7Ôµĵ®Éúʯruby£¨ºì±¦Ê¯£©ÃüÃû¡£railsÔÚÓ¢ÎÄÖÐÊÇÀ¸¸ËµÄ ......

windows ÏÂrubyµÄ°²×°

1£¬°²×°ruby
ÏÂÔصØÖ·£º http://rubyinstaller.org/download.html
2£¬°²×°rails
ʹÓÃÃüÁîÏÂÔØ£ºÔÚÃüÁîÐÐÔËÐÐgem install rails --remote
2£¬³õ²½Á˽ârubyµÄÎÄÕÂ
http://www.bcbbs.net/html/29671.html
http://www.bcbbs.net/dev/List64.aspx ......

Ruby on Rails ÃüÁî²Î¿¼

1.1.Rails
1.1 ´´½¨Ò»¸öRailsÓ¦ÓóÌÐò
$ rails app_name
¿ÉÑ¡Ïî:
-d, database=xxx Ö¸¶¨°²×°Ò»¸öÊý¾Ý¿â(mysql oracle postgresql sqlite2 sqlite3 ), ĬÈÏÇé¿öÏÂÊÇÊý¾Ý¿â
-r, ruby-path= Ö¸¶¨RubyµÄ°²×°Â·¾¶,Èç¹ûûÓÐÖ¸¶¨£¬scriptsʹÓÃenvÈ¥ÕÒRuby
-f, freeze (¶³½á)freezes RailsÔÚvendor/railsĿ¼
1.2 API Docume ......

netbeans + ruby + watir web×Ô¶¯²âÊÔ¿ò¼Ü´î½¨

ÕâÊÇÒ»¸ö¿ªÔ´£¬Ãâ·Ñ£¬ÁéÇÉ£¬¼òÒ×µÄweb×Ô¶¯»¯²âÊÔ×éºÏ¿ò¼Ü£»Í¨³£Çé¿ö£¬¿ªÔ´µÄ¶«Î÷×ÜÊǸøÈËÒÔÃÔÈË£¬¿ª·ÅʽµÄ´¥¸Ð£¬µ«Í¬Ê±£¬Ò²ÈÃÈËÄÑÒÔ¿ìËÙ½Ó½ü£¨ÏñÊǶ«·½ÄÐÈË¿´´ýÎ÷·½ÃÀÅ®£©£»ÒªÁ˽âÒ»¸ö¿ªÔ´¶øÇÒ×éºÏƯÁÁµÄ¿ò¼Ü£¬×ÜÊÇÒª·ÑЩÖÜÕÂ......×ܶøÑÔÖ®£¬Ëü²»»áÏñÊշѵĶ«Î÷£¬ÄãºÜÌÖÑáËü£¬µ«²»¿É·ñÈÏ£¬ÄãµÄ¸¶·ÑÆäʵ»»È¡Á˱ðÈ˵ÄËöËéÀͶ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ