1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Revert "Revert "More 1.9 way""

Fixed failing tests
This reverts commit 8350ce97f2.
This commit is contained in:
Santiago Pastorino 2012-01-06 10:48:47 -02:00
parent 6e6764b3a1
commit fc956425d4
2 changed files with 4 additions and 4 deletions

View file

@ -867,6 +867,7 @@ class FormHelperTest < ActionView::TestCase
def test_form_for_with_remote_without_html
@post.persisted = false
def @post.id; nil; end
form_for(@post, :remote => true) do |f|
concat f.text_field(:title)
concat f.text_area(:body)
@ -1016,6 +1017,7 @@ class FormHelperTest < ActionView::TestCase
old_locale, I18n.locale = I18n.locale, :submit
@post.persisted = false
def @post.id; nil; end
form_for(@post) do |f|
concat f.submit
end

View file

@ -39,11 +39,9 @@ module ActiveModel
# Returns an Enumerable of all key attributes if any is set, regardless
# if the object is persisted or not.
#
# Note the default implementation uses persisted? just because all objects
# in Ruby 1.8.x responds to <tt>:id</tt>.
def to_key
persisted? ? [id] : nil
key = respond_to?(:id) && id
key ? [key] : nil
end
# Returns a string representing the object's key suitable for use in URLs,