Skip to content

Commit

Permalink
fix: hydrate resource with record when detect_fields on new (#2659)
Browse files Browse the repository at this point in the history
* fix: hydrate resource with record when detect_fields on new

* refactor

* wip

* fix
  • Loading branch information
Paul-Bob authored Apr 4, 2024
1 parent 52d034d commit 9c380ac
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/controllers/avo/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class BaseController < ApplicationController
before_action :set_resource
before_action :set_applied_filters, only: :index
before_action :set_record, only: [:show, :edit, :destroy, :update, :preview]
before_action :set_record_to_fill, only: [:new, :edit, :create, :update]
before_action :detect_fields
before_action :set_record_to_fill
before_action :set_edit_title_and_breadcrumbs, only: [:edit, :update]
before_action :fill_record, only: [:create, :update]
# Don't run base authorizations for associations
Expand Down Expand Up @@ -102,8 +102,9 @@ def show
end

def new
@record = @resource.model_class.new
@resource = @resource.hydrate(record: @record, view: :new, user: _current_user)
# Record is already hydrated on set_record_to_fill method
@record = @resource.record
@resource.hydrate(view: :new, user: _current_user)

# Handle special cases when creating a new record via a belongs_to relationship
if params[:via_belongs_to_resource_class].present?
Expand Down

0 comments on commit 9c380ac

Please sign in to comment.