Skip to content
Snippets Groups Projects
Unverified Commit 6a5a9647 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

Revert "slug validator"

This reverts commit c1672fb3.
parent c1672fb3
No related branches found
No related tags found
No related merge requests found
...@@ -39,8 +39,6 @@ class Communication::Website::Author < ApplicationRecord ...@@ -39,8 +39,6 @@ class Communication::Website::Author < ApplicationRecord
class_name: 'Communication::Website::Post', class_name: 'Communication::Website::Post',
dependent: :nullify dependent: :nullify
validates :slug, uniqueness: { scope: :website_id }
scope :ordered, -> { order(:last_name, :first_name) } scope :ordered, -> { order(:last_name, :first_name) }
def to_s def to_s
......
...@@ -59,7 +59,6 @@ class Communication::Website::Category < ApplicationRecord ...@@ -59,7 +59,6 @@ class Communication::Website::Category < ApplicationRecord
validates :name, presence: true validates :name, presence: true
validates :slug, uniqueness: { scope: :website_id }
scope :ordered, -> { order(:position) } scope :ordered, -> { order(:position) }
......
...@@ -63,7 +63,6 @@ class Communication::Website::Page < ApplicationRecord ...@@ -63,7 +63,6 @@ class Communication::Website::Page < ApplicationRecord
dependent: :nullify dependent: :nullify
validates :title, presence: true validates :title, presence: true
validates :path, uniqueness: { scope: :website_id }
before_validation :make_path before_validation :make_path
after_save :update_children_paths if :saved_change_to_path? after_save :update_children_paths if :saved_change_to_path?
......
...@@ -49,12 +49,11 @@ class Communication::Website::Post < ApplicationRecord ...@@ -49,12 +49,11 @@ class Communication::Website::Post < ApplicationRecord
foreign_key: 'communication_website_post_id', foreign_key: 'communication_website_post_id',
association_foreign_key: 'communication_website_category_id' association_foreign_key: 'communication_website_category_id'
validates :title, presence: true
validates :slug, uniqueness: { scope: :website_id }
scope :ordered, -> { order(published_at: :desc, created_at: :desc) } scope :ordered, -> { order(published_at: :desc, created_at: :desc) }
scope :recent, -> { order(published_at: :desc).limit(5) } scope :recent, -> { order(published_at: :desc).limit(5) }
validates :title, presence: true
def github_path_generated def github_path_generated
"_posts/#{published_at.year}/#{published_at.strftime "%Y-%m-%d"}-#{slug}.html" "_posts/#{published_at.year}/#{published_at.strftime "%Y-%m-%d"}-#{slug}.html"
end end
......
...@@ -2,6 +2,8 @@ module WithSlug ...@@ -2,6 +2,8 @@ module WithSlug
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
validates :slug,
uniqueness: { scope: :university_id }
validates :slug, validates :slug,
format: { with: /\A[a-z0-9\-]+\z/, message: I18n.t('slug_error') } format: { with: /\A[a-z0-9\-]+\z/, message: I18n.t('slug_error') }
end end
......
...@@ -36,8 +36,6 @@ class Education::Teacher < ApplicationRecord ...@@ -36,8 +36,6 @@ class Education::Teacher < ApplicationRecord
association_foreign_key: 'education_program_id' association_foreign_key: 'education_program_id'
has_many :websites, -> { distinct }, through: :programs has_many :websites, -> { distinct }, through: :programs
validates :slug, uniqueness: { scope: :university_id }
scope :ordered, -> { order(:last_name, :first_name) } scope :ordered, -> { order(:last_name, :first_name) }
def to_s def to_s
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment