docbrown/lib/data_update_scripts/20220126102900_create_home_navigation_link.rb
Anna Buianova 784afdf41e
Routine rubocop fixes (#19254)
* Rubocop fixes

* Rubocop fixes

* Fixed rubocop violation

* Fixed policies rubocop violations

* More rubocop fixes
2023-03-24 14:37:44 +03:00

20 lines
638 B
Ruby

module DataUpdateScripts
class CreateHomeNavigationLink
def run
NavigationLink.create_or_update_by_identity(
name: "Home",
url: URL.url("/"),
icon: Rails.root.join("app/assets/images/twemoji/house.svg").read,
display_only_when_signed_in: false,
position: 1,
section: :default,
)
# Increment all other default section links to account for new home link, and update to be 1-based
NavigationLink.where(section: :default).find_each do |link|
new_position = link.position + 2
link.update_columns(position: new_position)
end
end
end
end