Skip to content

Commit

Permalink
Fix dynamic model detection (from_get_recordset).
Browse files Browse the repository at this point in the history
  • Loading branch information
gregschmit committed Feb 16, 2023
1 parent a9cbaad commit 92f4b38
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/rest_framework/controller_mixins/models.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require_relative "base"
require_relative "../filters"

require "action_controller/test_case"

# This module provides the core functionality for controllers based on models.
module RESTFramework::BaseModelControllerMixin
include RESTFramework::BaseControllerMixin
Expand Down Expand Up @@ -85,7 +87,7 @@ def get_model(from_get_recordset: false)
unless from_get_recordset
# Instantiate a new controller to get the recordset.
controller = self.new
controller.request = ActionController::TestRequest.new
controller.request = ActionController::TestRequest.new({}, {}, controller)
controller.params = {}

if (recordset = controller.get_recordset)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
class TestApi::MarblesWithAddedSelectController < TestApiController
include RESTFramework::ModelControllerMixin

self.model = Marble
self.native_serializer_config = {except: [:price]}

def get_recordset
return super.select("*, 5 as selected_value")
return Marble.select("*, 5 as selected_value")
end
end

0 comments on commit 92f4b38

Please sign in to comment.