lib/sn_foil/controller/api.rb in snfoil-rails-0.5.0 vs lib/sn_foil/controller/api.rb in snfoil-rails-0.5.1

- old
+ new

@@ -39,11 +39,14 @@ end def render_change(model, **options) if model.errors.empty? params - render json: serializer(**options).new(model, **options.merge, params: { current_entity: current_entity }).serializable_hash + render json: serializer(**options).new(model, + **options, + params: (options[:controller_params] || options[:params] || {}) + .merge(current_entity: current_entity)).serializable_hash else render json: model.errors, status: :unprocessable_entity end end @@ -56,16 +59,20 @@ end def render_index(results, **options) render json: serializer(**options).new(paginate(results, **options), **options, - params: { current_entity: current_entity }, + params: (options[:controller_params] || options[:params] || {}) + .merge(current_entity: current_entity), meta: meta(results, **options)) .serializable_hash end def render_show(model, **options) - render json: serializer(**options).new(model, **options, params: { current_entity: current_entity }).serializable_hash + render json: serializer(**options).new(model, + **options, + params: (options[:controller_params] || options[:params] || {}) + .merge(current_entity: current_entity)).serializable_hash end private def inject_deserialized_params(**options)