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
Ïà¹ØÎĵµ£º
b = "123"
a = b
b.gsub!(/2/,"")
puts a
µÃµ½µÄ½á¹ûÊÇ13£¬·¢ÏÖÈç¹ûa = bµÄ»°Ã²ËÆÖ»ÊÇ°ÑbµÄÖ¸Õë¸øÁËa£¬µ«ÊÇÈç¹ûbµÄÖµ·¢ÉúÁ˱仯a²ÅÄÜ´ÓbÖжÀÁ¢³öÀ´¡£
Èç¹û°ÑÉÏÃæµÄ´úÂë¸Ä³É
b = "123"
a = "#{b}"
b.gsub!(/2/,"")
puts a
ÔòµÃµ½µÄ½á¹ûΪ123£¬ÕâÀïÊÇ°ÑbµÄÖµ¸øÁ ......
ת×Ô http://www.advidea.cn/biancheng/200943135232.html
Ruby watir ²âÊÔ¿ò¼Ü
´ó¶àÊýÈ˶¼»á°²×° ruby,
Ҳͨ¹ýRuby °²×° gem,
Ò²°²×°ÁËruby IDE¿ª·¢¹¤¾ß£ºnetbeans,
µ«¾ÍÊDz»ÄÜÅÜwatir»·¾³£¬¿ñÔμÓÍÂÖС£¡£¡£
´íÎóÈçÏ£º
in `require': no such file to load -- watir (LoadError)
·´Õý¾ÍÊÇÕÒ²»µ½watir,ÕâÀï ......
ÎÒÃÇÔÚʹÓÃC±à³Ìʱ»áÓöµ½Ò»¸öÎÊÌ⣬±ÈÈçÍ·ÎļþµÄÒ»¸öº¯Êý°üº¬ÔÚÒ»¸ölibÖУ¬µ«ÊÇ
ÔÚʵ¼ÊÁ¬½ÓÖÐÎÒÃDz»ÖªµÀËüÔÚÄĸö¿âÖС£Ò²Ðí¿ÉÐеÄÒ»ÖÖ°ì·¨ÊÇÖ±½ÓÉÏÍø²éѯij¸ö
º¯ÊýµÄÒÀÀµÌõ¼þ£¬Õâ¶ÔÓÚ³£Óú¯ÊýÊÇûÎÊÌâµÄ£¡µ«ÊǶÔÓÚ¸´ÔÓ¶øÓÖȱÉÙÎĵµµÄµÚÈý·½
libÀ´Ëµ£¬ÎÞÒìÓÚ´óº£ÀÌÕë¡£
×Ô´Ëͨ¹ý2ÖÖ°ì·¨À´³¢ÊÔ½â¾öÕâ¸öÎÊÌ⣬ÎÒÃÇÏÈ¿´µÚÒ» ......
ʹÓà will_paginate ½øÐзÖÒ³ºÍ¼òµ¥²éѯ
ÔÚÃüÁîÐÐÏÂʹÓà gem install will_paginate ÃüÁ³öÏÖÏÂÃæ½á¹û°²×°³É¹¦
´ò¿ª books_controller.rb (Äã×Ô¼ºµÄ¿ØÖÆÆ÷)
×¢Ê͵ô²éÕÒÈ«²¿µÄ·½·¨£¬Ê¹ÓÃÏÂÃæµÄ·½·¨£¬ÒѾ¼¯³É¸ù¾Ýtitle½øÐвéѯ
Ruby´úÂë
#@books = Book.all
@books = Book.pagina ......