Ruby on Rails :: Deprecation
Posted by PunNeng, Wed May 30 05:03:00 UTC 2007
กำลังทำงานอยู่บน Rails แล้วก็ดู log ไป ไปเจอข้อความแบบนี้เข้า
DEPRECATION WARNING: start_form_tag is deprecated and will be removed from Rails 2.0 (use form_tag instead) See http://www.rubyonrails.org/deprecation for details. (called from _run_rhtml_47app47views47home47_account46rhtml at script/../config/../app/views/home/_account.rhtml:2)
อ้า บางอย่างจะหยุดใช้ใน Rails 2.0 (ตอนนี้ 1.2.3)
ตาม link จะเจอ list นี้
Action Pack
- components
- use partials and helper methods instead
- @params, @session, @flash, @request, @cookies, @headers, @response
- Use the params, session, flash, etc methods instead of working with the instance variables directly.
- url_for(:symbol, *args), redirect_to(:symbol, *args)
- use named routes instead
- render_text, render_template, etc.
- Use e.g. render :text => ..., render :template => ..., etc.
- redirect_to_path, redirect_to_url.
- Use redirect_to.
- post_format, formatted_post?, xml_post?, yaml_post?
- Use respond_to or request.format.
- start_form_tag and end_form_tag
- Use form_tag with a block.
- update_element_function
- use RJS
- link_to_image, link_image_to helper methods
- use link_to(image_tag(..), url)
- human_size helper alias
- use number_to_human_size helper method
Active Record
- find_first, find_all
- Use find :first and find :all.
- push_with_attributes
- Use has_many :through for rich many-to-many associations.
- *association*_count
- Use *association*.count instead
Railties
- Non-namespaced rake tasks like rake migrate.
- Use rake db:migrate.
ที่ผมใช้บ่อยๆ ในงานเก่า จะเป็น start_form_tag อย่างเดียว สงสัยต้องตามแก้กันเยอะเลย =='
ส่วนงานใหม่ใช้ scaffold_resource สร้างเอา สบายกว่ากันเยอะเลย
สร้าง form builder ให้เลย แล้วจะมาแสดงวิธีใช้ from builder ให้ดูครับ :)