diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-07-20 00:58:59 +0900 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-07-20 00:58:59 +0900 |
commit | 13e18dd94000cef2b2058b96d62de16b7d3a2200 (patch) | |
tree | 54b5cbd18b31066744e67e226d8d603f70a5f8c6 /actionpack/lib/action_view/helpers/active_record_helper.rb | |
parent | 5ffaaa71d149c9807260c950c9a61d01fe734827 (diff) | |
download | rails-13e18dd94000cef2b2058b96d62de16b7d3a2200.tar.gz rails-13e18dd94000cef2b2058b96d62de16b7d3a2200.tar.bz2 rails-13e18dd94000cef2b2058b96d62de16b7d3a2200.zip |
Update some tests and add a to_model to form helpers
Diffstat (limited to 'actionpack/lib/action_view/helpers/active_record_helper.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/active_record_helper.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/active_record_helper.rb b/actionpack/lib/action_view/helpers/active_record_helper.rb index 8dffd3bc91..409b27de73 100644 --- a/actionpack/lib/action_view/helpers/active_record_helper.rb +++ b/actionpack/lib/action_view/helpers/active_record_helper.rb @@ -77,7 +77,7 @@ module ActionView # * <tt>:submit_value</tt> - The text of the submit button (default: "Create" if a new record, otherwise "Update"). def form(record_name, options = {}) record = instance_variable_get("@#{record_name}") - record = record.to_model if record.respond_to?(:to_model) + record = convert_to_model(record) options = options.symbolize_keys options[:action] ||= record.new_record? ? "create" : "update" @@ -122,7 +122,7 @@ module ActionView end options.reverse_merge!(:prepend_text => '', :append_text => '', :css_class => 'formError') - object = object.to_model if object.respond_to?(:to_model) + object = convert_to_model(object) if (obj = (object.respond_to?(:errors) ? object : instance_variable_get("@#{object}"))) && (errors = obj.errors[method]) @@ -182,7 +182,7 @@ module ActionView objects = params.collect {|object_name| instance_variable_get("@#{object_name}") }.compact end - objects.map! {|o| o.respond_to?(:to_model) ? o.to_model : o } + objects.map! {|o| convert_to_model(o) } count = objects.inject(0) {|sum, object| sum + object.errors.count } unless count.zero? |