app/controllers/simple_admin/resources_controller.rb in simpleadmin-1.0.3 vs app/controllers/simple_admin/resources_controller.rb in simpleadmin-1.1.0
- old
+ new
@@ -1,10 +1,10 @@
module SimpleAdmin
class ResourcesController < BaseController
def index
model_klass = params[:model_klass_name].constantize
- model_fields = params[:model_fields]
+ model_fields = params[:model_fields].map { |field_attributes| field_attributes[:field_name] }
per_page = params[:per_page].to_i
page = params[:page].to_i if params[:page].present?
total = model_klass.count
@@ -43,10 +43,10 @@
}
end
def show
model_klass = params[:model_klass_name].constantize
- model_fields = params[:model_fields]
+ model_fields = params[:model_fields].map { |model_field| model_field['field_name'] }
resource = model_klass.find(params[:id]).attributes.slice(*model_fields)
render json: resource
end