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 3b39cc5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/controllers/homepage_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def show
end

def create
params.permit(popular_links: %i[title url])
@latest_popular_links = @latest_popular_links.create_draft_popular_links_from_last_record
render "homepage/popular_links/show"
end
Expand All @@ -19,7 +20,9 @@ def edit
end

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

Check failure on line 23 in app/controllers/homepage_controller.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Layout/EmptyLinesAroundMethodBody: Extra empty line detected at method body beginning. (https://rubystyle.guide#empty-lines-around-bodies)
create_params = params.permit(popular_links: %i[title url])
@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 @@ -108,7 +111,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 3b39cc5

Please sign in to comment.