Remove redundant conditions in content blocks controller

In the case of the `edit` action, we're using
`load_and_authorize_resource`, which will always return a
`SiteCustomization::ContentBlock`. In the case of
`edit_heading_content_block`, we're using `Budget::ContentBlock.find`,
which always returns a `Budget::ContentBlock` (or raises an exception).

So, in both cases, the condition to assign `@selected_content_block` can
be removed.
This commit is contained in:
Javi Martín
2024-05-23 19:45:29 +02:00
parent e7d2cfbf23
commit 1898bdec56

View File

@@ -34,11 +34,7 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
end end
def edit def edit
if @content_block.is_a? SiteCustomization::ContentBlock
@selected_content_block = @content_block.name @selected_content_block = @content_block.name
else
@selected_content_block = "hcb_#{@content_block.heading_id}"
end
end end
def update def update
@@ -75,11 +71,7 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
def edit_heading_content_block def edit_heading_content_block
@content_block = Budget::ContentBlock.find(params[:id]) @content_block = Budget::ContentBlock.find(params[:id])
if @content_block.is_a? Budget::ContentBlock
@selected_content_block = "hcb_#{@content_block.heading_id}" @selected_content_block = "hcb_#{@content_block.heading_id}"
else
@selected_content_block = @content_block.name
end
@is_heading_content_block = true @is_heading_content_block = true
render :edit render :edit
end end