Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hydrate resource with record when detect_fields on new #2659

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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