Commit 6257cfe5 by liyijie

feat: 更新update! 方法,使用的resource_params是数组

parent 2a9ff66d
......@@ -41,12 +41,13 @@ class SimpleController::BaseController < ::InheritedResources::Base
def update!(options={}, &block)
# 可以传入resource_params进行方法复用
_resource_params = Array.new(options.delete(:resource_params) || resource_params)
_resource_params = options.delete(:resource_params)
_update_params = _resource_params.present? ? [_resource_params] : resource_params
options = { template: "#{self.class.view_path}/show", status: 201 }.merge options
object = resource
if update_resource(object, _resource_params)
if update_resource(object, _update_params)
options[:location] ||= smart_resource_url
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment