From a6ada355d9314dcf6222bf477a103683770b47c1 Mon Sep 17 00:00:00 2001 From: Dmitry Lihachev Date: Wed, 26 Jan 2011 19:09:20 +0800 Subject: [PATCH] search object attributes in params[resource_instance_name] if they params[resource_request_name] empty --- lib/inherited_resources/actions.rb | 2 +- lib/inherited_resources/base_helpers.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/inherited_resources/actions.rb b/lib/inherited_resources/actions.rb index cee2f3a7..7a618aa7 100644 --- a/lib/inherited_resources/actions.rb +++ b/lib/inherited_resources/actions.rb @@ -42,7 +42,7 @@ def create(options={}, &block) def update(options={}, &block) object = resource - if update_resource(object, params[resource_request_name]) + if update_resource(object, params[resource_request_name] || params[resource_instance_name]) options[:location] ||= smart_resource_url end diff --git a/lib/inherited_resources/base_helpers.rb b/lib/inherited_resources/base_helpers.rb index 8b6acf60..a616b536 100644 --- a/lib/inherited_resources/base_helpers.rb +++ b/lib/inherited_resources/base_helpers.rb @@ -49,7 +49,7 @@ def resource # instance variable. # def build_resource - get_resource_ivar || set_resource_ivar(end_of_association_chain.send(method_for_build, params[resource_request_name] || {})) + get_resource_ivar || set_resource_ivar(end_of_association_chain.send(method_for_build, params[resource_request_name] || params[resource_instance_name] || {})) end # Responsible for saving the resource on :create method. Overwriting this