Ruby formµÄÁ½ÖÖд·¨
ÏÂÃæ½éÉÜRuby formµÄÁ½ÖÖд·¨¡£
Ruby formд·¨Ò»£ºÊ¹ÓÃform_for
< % form_for :order, :url => { :action => :save_order } do |form| %> < p> < %= label :order, :name, "Name:" %> < %= form.text_field :name, :size => 40 %> < /p> < p> < %= label :order, :address, "Address:" %> < %= form.text_area :address, :rows => 3, :cols => 40 %> < /p> < p> < %= label :order, :email, "E-Mail:" %> < %= form.text_field :email, :size => 40 %> < /p> < %= submit_tag "Place Order" , :class => "submit" %> < % end %>
À´¿´¿´½âÊÍ
ÒýÓÃ
There are two interesting things in this code. First, the form_for helper on line 1 sets up a standard HTML form. But it does more. The first parameter, : order,tells the method that it’s dealing with an object in an instance variable named @order. The helper uses this information when naming fields and when arranging for the field values to be passed back to the controller.
The :url parameter tells the helper what to do when the user hits the submit button. In this case, we’ll generate an HTTP POST request that’ll end up getting handled by the save_order action in the controller.
¶øÃ¿¸öformµÄhelper·½·¨£¬Èçform.text_area,form_text_field,ºóÃæ¸úµÄ·ûºÅ£¬Èç:name,:address,:email£¬µÈ¶¼ÊÇÕâ¸ömodelµÄÊôÐÔ¡£form_f
Ïà¹ØÎĵµ£º
ÁùÖÖÓÃrubyµ÷ÓÃÖ´ÐÐshellÃüÁîµÄ·½·¨
Åöµ½ÐèÒªµ÷ÓòÙ×÷ϵͳshellÃüÁîµÄʱºò£¬RubyΪÎÒÃÇÌṩÁËÁùÖÖÍê³ÉÈÎÎñµÄ·½·¨£º
1.Exec·½·¨:
Kernel#exec·½·¨Í¨¹ýµ÷ÓÃÖ¸¶¨µÄÃüÁîÈ¡´úµ±Ç°½ø³Ì£º
Àý×Ó£º
$ irb
>> exec 'echo " ......
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 ......
ת 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 ......
ÕâÊÇÒ»¸ö¿ªÔ´£¬Ãâ·Ñ£¬ÁéÇÉ£¬¼òÒ×µÄweb×Ô¶¯»¯²âÊÔ×éºÏ¿ò¼Ü£»Í¨³£Çé¿ö£¬¿ªÔ´µÄ¶«Î÷×ÜÊǸøÈËÒÔÃÔÈË£¬¿ª·ÅʽµÄ´¥¸Ð£¬µ«Í¬Ê±£¬Ò²ÈÃÈËÄÑÒÔ¿ìËÙ½Ó½ü£¨ÏñÊǶ«·½ÄÐÈË¿´´ýÎ÷·½ÃÀÅ®£©£»ÒªÁ˽âÒ»¸ö¿ªÔ´¶øÇÒ×éºÏƯÁÁµÄ¿ò¼Ü£¬×ÜÊÇÒª·ÑЩÖÜÕÂ......×ܶøÑÔÖ®£¬Ëü²»»áÏñÊշѵĶ«Î÷£¬ÄãºÜÌÖÑáËü£¬µ«²»¿É·ñÈÏ£¬ÄãµÄ¸¶·ÑÆäʵ»»È¡Á˱ðÈ˵ÄËöËéÀͶ ......
ʹÓà will_paginate ½øÐзÖÒ³ºÍ¼òµ¥²éѯ
ÔÚÃüÁîÐÐÏÂʹÓà gem install will_paginate ÃüÁ³öÏÖÏÂÃæ½á¹û°²×°³É¹¦
´ò¿ª books_controller.rb (Äã×Ô¼ºµÄ¿ØÖÆÆ÷)
×¢Ê͵ô²éÕÒÈ«²¿µÄ·½·¨£¬Ê¹ÓÃÏÂÃæµÄ·½·¨£¬ÒѾ¼¯³É¸ù¾Ýtitle½øÐвéѯ
Ruby´úÂë
#@books = Book.all
@books = Book.pagina ......