Skip to content

Commit

Permalink
revert fix: keep original view after run update or create actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob committed Mar 18, 2024
1 parent 052c81f commit e04a533
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions app/controllers/avo/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,13 @@ def model_scope
@resource.class.find_scope
end

# Force actions to have specific view
VIEW_ACTION_MAPPING = {
update: :edit,
create: :new
} unless defined? VIEW_ACTION_MAPPING

def set_view
@view = Avo::ViewInquirer.new(VIEW_ACTION_MAPPING[action_name.to_sym] || action_name)
@view = Avo::ViewInquirer.new(action_name.to_s)
end

def set_record_to_fill
@record_to_fill = if @view.new?
@resource.model_class.new
elsif @view.edit?
@record
end
@record_to_fill = @resource.model_class.new if @view.create?
@record_to_fill = @record if @view.update?

# If resource.record is nil, most likely the user is creating a new record.
# In that case, to access resource.record in visible and readonly blocks we hydrate the resource with a new record.
Expand Down

0 comments on commit e04a533

Please sign in to comment.