docbrown/app/models/navigation_link.rb
Ridhwana 66b14fc0bf
[deploy] Dynamic frontend for the sidebar navigation Items (#10754)
* feat: configure the frontend for sidebar nav links

* chore: add a comment

* changes to the admin interface

* feat: move the temporary task to be in the rake tasks and use it in the dev seeds

* feat: use the task in the rake seeds

* refactor: reuse the form across two modals

* refactor: use the form partial

* feat: change the modal to be large

* fix: naming

* Update db/seeds.rb

Co-authored-by: Michael Kohl <me@citizen428.net>

* chore: make the file readable

* chore: removed the if else as the rake task was run on all forems + i sent out a message to new communities

* oops

* refactor: add a scope

* chore: oops removed this

* feat: add navigation links specs

* spec: fix two failing ones

Co-authored-by: Michael Kohl <me@citizen428.net>
2020-10-12 16:05:47 -04:00

10 lines
381 B
Ruby

class NavigationLink < ApplicationRecord
SVG_REGEXP = /<svg .*>/i.freeze
validates :name, :url, :icon, presence: true
validates :url, url: { schemes: %w[https http] }, uniqueness: { scope: :name }
validates :icon, format: SVG_REGEXP
validates :display_only_when_signed_in, inclusion: { in: [true, false] }
scope :ordered, -> { order(position: :asc, name: :asc) }
end