Skip to content

Commit

Permalink
Fix homepage controller params to deal with BSON upgrade nuances
Browse files Browse the repository at this point in the history
  • Loading branch information
syed-ali-tw committed Sep 26, 2024
1 parent 2d44a1a commit 8b355b9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/controllers/homepage_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def edit
end

def update
@latest_popular_links.link_items = remove_leading_and_trailing_url_spaces(params[:popular_links].values)
create_params = permitted_params
@latest_popular_links.link_items = remove_leading_and_trailing_url_spaces(create_params[:popular_links].values)
@latest_popular_links.save_draft

flash[:success] = "Popular links draft saved.".html_safe
Expand Down Expand Up @@ -72,6 +73,10 @@ def confirm_destroy

private

def permitted_params
params.permit(popular_links: %i[title url])
end

def cannot_delete_published_error_message
"Can't delete an already published edition. Please create a new edition to make changes.".html_safe
end
Expand Down Expand Up @@ -108,7 +113,7 @@ def remove_leading_and_trailing_url_spaces(links)
link_items = []
links.each do |link|
link[:url] = link[:url].strip
link_items << link
link_items << link.to_h
end
link_items
end
Expand Down

0 comments on commit 8b355b9

Please sign in to comment.