O'Reilly logo

Rails Kochbuch by Rob Orsini

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

First
|
529
Max.
Linie
Max.
Linie
Anhang
ANHANG
Neue Features in Rails 1.2
Dieser Anhang führt Feature-Unterschiede und Änderungen zwischen Rails 1.1.6 und
Rails 1.2 auf. Alter (1.1.6) Code wird unter Rails 1.2 ausgeführt, aber Sie erhalten ent-
sprechende Warnungen, wenn Sie veraltete Features nutzen. Die Unterstützung veralteter
Features wird in der nächsten Haupt-Release von Rails (2.0) eingestellt.
ActionController
Tabelle A-1: Veraltete Controller-Instanzvariablen
Rails 1.1.6 Rails 1.2
@cookies cookies
@env env
@flash flash
@headers headers
@params params
@request request
@response response
@session session
Tabelle A-2: Veraltete Controller-Methoden
Rails 1.1.6 Rails 1.2
expire_matched_fragments expire_fragment
keep_flash flash.keep
parse_query_parameters parse_form_encoded_parameters
parse_request_parameters parse_form_encoded_parameters
redirect_to_path redirect_to(
path)
00____RailsKochbuch.book Seite 529 Dienstag, 3. Juli 2007 8:13 08
Max.
Linie
Max.
Linie
530
|
Anhang: Neue Features in Rails 1.2
Links
redirect_to_url redirect_to(url)
render('#{options}') render :file => #{options}
url_for(:#{options})
call url_for with a named route directly
Tabelle A-3: Veraltete Assertions
Rails 1.1.6 Rails 1.2
assert_assigned_equal assert_equal(expected, @response.template.assigns
[key.to_s])
assert_cookie_equal assert(@response.cookies.key?(key))
assert_flash_empty assert(!@response.has_flash_with_contents?)
assert_flash_equal assert_equal(expected, @response.flash[key])
assert_flash_exists assert(@response.has_flash?)
assert_flash_has assert(@response.has_flash_object?(key))
assert_flash_has_no assert(!@response.has_flash_object?(key))
assert_flash_not_empty assert(@response.has_flash_with_contents?)
assert_flash_not_exists assert(!@response.has_flash?)
assert_invalid_column_on_record assert(record.errors.invalid?(column))
assert_invalid_record assert(!assigns(key).valid?)
assert_no_cookie assert(!@response.cookies.key?(key))
assert_redirect assert_response(:redirect)
assert_redirect_url assert_equal(url, @response.redirect_url)
assert_redirect_url_match assert(@response.redirect_url_match?(pattern))
assert_rendered_file assert_template
assert_session_equal assert_equal(expected, @response[key])
assert_session_has assert(@response.has_session_object?(key))
assert_session_has_no assert(!@response.has_session_object?(key))
assert_success assert_response(:success)
assert_template_equal assert_equal(expected, @response.template.
assigns[key.to_s])
assert_template_has assert(@response.has_template_object?(key))
assert_template_has_no assert(!@response.has_template_object?(key))
assert_template_xpath_match assert_tag
assert_valid_record assert(assigns(key).valid?)
assert_valid_column_on_record assert(!record.errors.invalid?(column))
Tabelle A-2: Veraltete Controller-Methoden (Fortsetzung)
Rails 1.1.6 Rails 1.2
00____RailsKochbuch.book Seite 530 Dienstag, 3. Juli 2007 8:13 08
Max.
Linie
Max.
Linie
ActionView
|
531
Rechts
ActiveRecord
ActionView
Tabelle A-4: Weitere Änderungen
Rails 1.2
Components sind veraltet.
Alle Dependency-Loader, die früher im Modul Dependencies lagen, gehören nun zu ActiveSupport, und nicht mehr zu ActiveControl-
ler. Zu diesen gehören:
:depend_on, :dependencies_on, :model, :observer, :service.
Tabelle A-5: Veraltete Assoziationen
Rails 1.1.6 Rails 1.2
:dependent => true :dependent => :destroy
:exclusively_dependent :dependent => :delete_all
push_with_attributes
Wenn Assoziationen Attribute verlangen verwenden Sie has_many :through
concat_with_attributes
Wenn Assoziationen Attribute verlangen verwenden Sie has_many :through
Tabelle A-6: Veraltete Methoden
Rails 1.1.6 Rails 1.2
Zählen über Bedingungen oder Joins
count(column_name, options)
find_all find(:all, ...)
find_first find(:first, ...)
human_attribute_name .humanize
User.transaction(@user1, @user2) { ... } Die Unterstützung für Transaktionen auf Objektebene ist veraltet. Installieren Sie
das object_transactions-Plugin.
Tabelle A-7: Veraltete View-Features
Rails 1.1.6 Rails 1.2
content_for('name_of_content_block') yield :name_of_content_block
:human_size :number_to_human_size
link_image_to
use image_tag within a link_to method
:post as a link modifier use :method => "post" instead
render_partial use render :partial
render_partial_collection render :partial, :collection
<%= start_form_tag :action=>'list' %> ...
<%= end_form_tag %>
use new block form: <% form_tag :action=>'list'
do %> ... <% end %>
00____RailsKochbuch.book Seite 531 Dienstag, 3. Juli 2007 8:13 08
Max.
Linie
Max.
Linie
532
|
Anhang: Neue Features in Rails 1.2
Links
<%= form_remote_tag :update=>'list', :url=>
{:action=>'add'} %> ... <%= end_form_tag %>
use new block form: <% form_remote_tag :update=>
'list', :url=>{:action=>'add'} do %> ... <%
end %>
Tabelle A-7: Veraltete View-Features (Fortsetzung)
Rails 1.1.6 Rails 1.2
00____RailsKochbuch.book Seite 532 Dienstag, 3. Juli 2007 8:13 08

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required