Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : Ruby

Ruby Ò»²½²½°²×°


http://www.gayathri-frenzy.com/technology/ruby-on-rails
I kept thinking for a while on what do I have next in the store
Here we go “Ruby on Rails”
Ruby on Rails, often shortened to Rails or RoR, is an open source web application framework for the Ruby Programming language.Ruby is a pure object-oriented programming language with a super-clean syntax that makes programming elegant and fun.
What is Rails?
Rails is an open source Ruby framework for developing web-based, databasedriven applications. Dozens of frameworks are out and most of them have been around much longer than Rails. Why do we then have a different framework?
Rails help us in developing a web application at least ten times faster than we can with a typical Java framework. We can–without making any sacrifices in the quality of our application!
When I got started with this topic, I just lacked a proper installation guide to help me with the installation. So I’m trying to make my reader&rsq ......

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

ÎÄÕÂת×Ô http://www.ej38.com/showinfo/Ruby-140367.html 
¹ý³ÌÈçÏ£º
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 -l  ±¾µØ°²×°£©£º
http://rubyforge.org/frs/download.php/63167/rails-2.3.4.gem 
 
gem install -l rails-2.3.4.gem 
 
»áÌáʾÒÀÀµ£º
rails requires rake (>= 0.8.3, runtime
 
ÏÂÔØ
rake£º
http://rubyforge.org/frs/download.php/56871/rake-0.8.7.gem
 
¼ÌÐø
gem install -l rails-2.3.4.gem
ÌáʾÒÀÀµ£º
rails requires activesupport (= 2.3.4
ÏÂÔØ
activesupport £º
http://rubyforge.org/frs/download.php/63162/activesupport-2.3.4.gem
 
Èç´Ë£¬ÒÀ´ÎÏÂÔØËùÓÐÒÀÀµ£º
activerecord£º
http://rubyforge.org/frs/download.php/63163/activerecord-2.3.4.gem
actionpack£º
http://rubyforge.org/frs/ ......

ruby on rails ½â¾ömultiple select ´æ´¢ºÍupdate

²Ù×÷ϵͳubuntu£¬¿ª·¢¹¤¾ßnetbeans
vendorÊý¾Ý¿â±íÓÐ×Ö¶Îservice_category varchar(100)
<% form_for :vendor, @vendor, :url => sellers_path do |f| %>
  <%= f.select(:service_category,
                   ["Painting","Plumbing","Decor"], {}, {:multiple => true, :size => 3}) %>
  <%= f.submit "Register"%>
<% end %>
url Ö¸¶¨µ½Äĸöcontrol  action£¬ÓõÄÊÇrails rest¼¼Êõ
µ«ÊÇ´æÈëÊý¾Ý¿â±íµÄÊÇ--\painting --Ö®ÀàµÄ×Ö·û´®£¬²»·ûºÏÒªÇó
ËùÒÔÔÚvendor modelÖмÓÈë
def service_category=(values)
    if !values.nil?
          write_attribute('service_category', values.join(','))
    end
 end
 def service_category
    if !read_attribute('service_category').nil?
          read_attribute('service_categ ......

Rubyѧϰ±Ê¼ÇÒ»——ÓïÑÔ»ù´¡


#Ò»¡¢ÕâÀïÊÇ×¢ÊÍ£¬Êǵ¥ÐÐ×¢ÊÍ£¬ÀàËÆÓÚ//
puts 3/5#ÕâÀïÊÇÕûÊýÐÎʽµÄ½á¹û
puts 3/5.0#ÕâÀïÊÇСÊýÐÎʽµÄ½á¹û
=begin
  ÕâÊǶàÐÐ×¢ÊÍ£¬Êµ¼ÊÉÏÕâÒ²ÊÇRubyÄÚǶÎĵµ¸ñʽ£¬ÀàËÆÓÚJava doc
  =end²»µ«ÒªÓÐÆðÖ¹£¬»¹ÒªËõ½ø²ÅÓÐÓá£
=end
#¶þ¡¢Á¬ÐÐ
puts "Hello Ruby!"; puts "This is a "\
"String";#ÐÐβµÄ·ÖºÅ¿ÉÒÔÊ¡ÂÔ?‘\’ÊÇÁ¬Ðзû£¬ÐÐβ¼´Ä¬ÈÏΪһ¸öÓï¾äµÄ½áÊø£¬¿ÉÒÔûÓзֺţ¬Èç¹û²»Ï£ÍûËü½áÊøµ«Ïë»»ÐУ¬ÐèÒª¼ÓÁ¬Ðзû'\'ÇÒÖ®ºó²»ÄÜÔÙ¼ÓÐÐ×¢ÊÍ¡£
#Èý¡¢print,puts,printf
#puts¿ÉÒÔ¼Ó¶à¸ö²ÎÊýÔÚºóÃ棬ÿÊä³öÒ»¸ö²ÎÊý×Ô¶¯¼ÓÒ»¸ö»»Ðзû£¬¶øprint²»¼Ó»»Ðзû
puts "%d,%s",100,"string, hello!";
#ÓøñʽÂÀÊä³öÓеãÏñCÓïÑÔ·ç¸ñ,ÓÃprintf
printf "%d,%s",100,"string, hello!";
#ËÄ¡¢Ò»Ð©Ó﷨֪ʶ
#0¿ªÍ·±í8½øÖÆÊý£¬0x¿ªÍ·±í16½øÖÆÊý,0b¿ªÍ·±í¶þ½øÖÆ£¬µ¥ÒýºÅË«ÒýºÅ¶¼¿ÉÒý×Ö·û´®
#Ò»¸öÊý×éÖеÄÔªËØ¿ÉÒÔ»¥²»Ïàͬ£¬ÊÇÈõÀàÐÍÓïÑÔ
#Çø¼ä£º1..5±í1£¬2£¬3£¬4£¬5¡£1...5±íʾ1£¬2£¬3£¬4
#¸³Öµ¿ÉÓÃÕâÖÖÐÎʽa,b,c=3,4,5;
#±È½ÏÔËËãʱ¡£==×îÈõ£¬Ö»ÒªÖµÏàͬ¼´¿É£¬Èç1==1.0ΪÕ棬eql?Ç¿Ò»µã£¬ÐèҪֵΪÀàÐÍÏàͬ£¬Èç1==1£¬equal?×îÇ¿ÐèÒªÁ½¸ö±äÁ¿µÄµ ......

Rubyѧϰ±Ê¼Ç¶þ——Êý×é

#Ò»¡¢Êý×éÒýÓÃ
arr=[3,4,5,6,7,8,9]
puts arr[0] #3
puts arr.first #3
puts arr[arr.length-1] #9
puts arr[arr.size-1] #9
puts arr.last #9
puts arr[-1] #9
puts arr[-2] #8
print arr[1..3] ,"\n" #456
print arr[-3,4] ,"\n" #789£¬´Ó-3¿ªÊ¼ £¬´òÓ¡4¸öÔªËØ£¬ÕâÀïÖ»ÓÐÈý¸ö
#RubyµÄÊý×é´óСÊǶ¯Ì¬µÄ£¬ÄãÄܹ»ËæʱÔö¼Ó¡¢É¾³ýÊý×éÔªËØ¡£
print arr.join(", "),"\n" #Òâ˼ÊÇ£º½«Êý×éarrת»»³É×Ö·û´®Êä³ö£¬ÓÃ", "¸ô¿ªÃ¿¸öÔªËØ£¬²¢ÇÒ»»ÐС£
#¶þ¡¢Êý×é±à¼­
arr=[4,5,6]
print arr.join(", "),"\n" #4, 5, 6
arr[4] = "m" #°Ñ4ºÅË÷ÒýλÖÃÔªËظ³ÖµÎª"m"
print arr.join(", "),"\n" #4, 5, 6, , m
print arr[3] ,"\n" #´òÓ¡3ºÅË÷ÒýλÖÃÔªËØ #nil
arr.delete_at(3) #ɾ³ý3ºÅË÷ÒýλÖÃÔªËØ
print arr.join(", "),"\n" #4, 5, 6, m
arr[2] = ["a","b","c"] #°Ñ2ºÅË÷ÒýλÖÃÔªËظ³ÖµÎª["a","b","c"]
print arr.join(", "),"\n" #4, 5, a, b, c, m
print arr[2] ,"\n" #´òÓ¡2ºÅË÷ÒýλÖÃÔªËØ #abc
arr[0..1] = [7,"h","b"] #°Ñ0..1ºÅÔªËØÌ滻Ϊ7,"h","b"
puts arr[0];#ÓÉÊä³ö¿É¼û£¬ÔªËظöÊý¼ÓÁËÒ»¸ö£¬¼´Ìæ»»Ö®ºó£¬³ÉÁË0..2¶ÔÓ¦7,h,b
puts arr[1];
puts arr[2];
......

Rubyѧϰ±Ê¼ÇÈý——Àà


#Ò»¡¢¶¨ÒåÒ»¸öÀà
class Person
  def initialize(name,age=18)
    @name=name;
    @age=age;
    @motherland="china";
  end
  def talk
    puts "my name is "+@name+" and I am "+@age.to_s
    if @motherland == "china"
      puts "I am a Chinese."
    else
      puts "I am a foreigner."
    end
  end#talk½áÊø
  attr_writer:motherland 
  attr_writer:age
end#class½áÊø
p1=Person.new("Zhangren",10);
p1.talk;
p1.motherland="abc";
p1.talk;
p1.age=20;
p1.talk;
#¶þ¡¢¼Ì³Ð×ÔÒ»¸öÀà
class Student < Person
  def talk
    #super;#Õâ»áµ÷Óø¸ÀàtalkÖеĴúÂë
    puts "I am a student. my name is "+@name+", age is "+@age.to_s
  end # talk·½·¨½áÊø
end # StudentÀà½áÊø
p3=Student.new("kaichuan",25); p3.talk
p4=Student.new( ......
×ܼǼÊý:146; ×ÜÒ³Êý:25; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [9] [10] [11] [12] 13 [14] [15] [16] [17] [18]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ