Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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·þÎñÆ


Ïà¹ØÎĵµ£º

Install Cassandra with Ruby 1.9.1 on Windows

To get it done is not easy. I spent a whole day to figure out the various compatibility issues along the way out.
Now there still might be potential issues, but it works by my rough test.
Step 1: Install Apache Cassandra
  You may know that the Ruby gem cassandra will do it for you.
  ......

RubyÉùÒô


ת Adding Sound to Your Ruby Apps
Have you ever thought about including sounds in your Ruby application? Used sparingly, sound may enhance your applications by adding audio cues or a custom touch. You could, for example, play a beep or chime that announces the completion of a lengthy process. Per ......

Windowsƽ̨µÄruby IDE µãÆÀ

ת×Ô http://www.javaeye.com/topic/57474 
Windowsƽ̨µÄruby IDE µãÆÀ
ÔÚMacOSƽ̨¼¸ºõûÓÐʲôÕùÒéÐÔ£¬´ó¼Ò¶¼ÓÃTextMate¡£µ«ÊÇWindowsƽ̨¿É¹©Ñ¡ÔñºÍʹÓõÄIDEºÜ¶à£¬È´¸÷Óи÷µÄ³¤´¦ºÍ¶Ì´¦¡£»ùÓÚÎÒÓùýµÄËùÓÐruby IDEµãÆÀһϡ£windowsƽ̨µÄRoR IDEÖ÷Òª·ÖΪÁ½ÀࣺһÀàÊÇÖØÁ¿¼¶µÄÈ«¹¦ÄÜIDE£¬ÀýÈçEclipse£¬Netbeans ......

rubyÀà±äÁ¿ÔÚdevelopmentģʽʧЧ

·ÖÒ³ÖÐÓõ½Àà±äÁ¿£¬Ö÷ÒªÊÇÓÃÀ´±ê¼Ç¡°Ò³ÂëÊäÈë¿ò¡±µÄid Èç¹ûÒ»¸öÒ³ÃæÓм¸¸ö·ÖÒ³£¬¡°Ò³ÂëÊäÈë¿ò¡±µÄidÒªÊDz»Í¬µÄ²ÅÄÜ·ÖÇåÊÇÄĸöÒª·ÖÒ³¡£Ê¹ÓÃÀà±äÁ¿¾ÍÊÇΪÁË´ïµ½Õâ¸öÄ¿µÄ£¬ÈÃËùÓеĶÔÏóʵÀý¹²ÓÃÒ»¸ö±äÁ¿£¬²»±Øÿ´ÎÖØгõʼ»¯±äÁ¿¡£ Àà±äÁ¿Ê¹ÓôúÂëʾÀý 1 require 'ruby-debug'
2 debugger
3 cla ......

rubyµÄÀàÓëÄ£¿é£¨1£©

class Point
@x = 1
@y = 2
def initialize(x,y)
@x,@y = x,y
end
end 
´úÂëÖеÄ@x£¬@yΪʵÀý±äÁ¿£¬ÊµÀý±äÁ¿Ö»¶ÔselfµÄ»·¾³Æð×÷Óã¬Òò´ËinitializeÍâÃæµÄ@x=1£¬@y=2Ö»¶ÔÀà±¾ÉíÆð×÷Ó㬶ø·½·¨ÄÚ²¿£¬µÄ@x£¬@yÊǶԶÔÏóµÄʵÀýÆð×÷Óõġ£
class Point
include Enumerable
def initialize(x ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ