Sha256: 221af71a2fb21cb581014a8295e33514e69a4fc685b50321a5bf6bf2ff1c39cd
Contents?: true
Size: 1.72 KB
Versions: 2
Compression:
Stored size: 1.72 KB
Contents
module FriendlyId # @guide begin # # ## Reserved Words # # The {FriendlyId::Reserved Reserved} module adds the ability to exclude a list of # words from use as FriendlyId slugs. # # With Ruby on Rails, FriendlyId's generator generates an initializer that # reserves some words such as "new" and "edit" using {FriendlyId.defaults # FriendlyId.defaults}. # # Note that the error messages for fields will appear on the field # `:friendly_id`. If you are using Rails's scaffolded form errors display, then # it will have no field to highlight. If you'd like to change this so that # scaffolding works as expected, one way to accomplish this is to move the error # message to a different field. For example: # # class Person < ActiveRecord::Base # extend FriendlyId # friendly_id :name, use: :slugged # # after_validation :move_friendly_id_error_to_name # # def move_friendly_id_error_to_name # errors.add :name, *errors.delete(:friendly_id) if errors[:friendly_id].present? # end # end # # @guide end module Reserved # When included, this module adds configuration options to the model class's # friendly_id_config. def self.included(model_class) model_class.class_eval do friendly_id_config.class.send :include, Reserved::Configuration validates_exclusion_of :friendly_id, in: ->(_) { friendly_id_config.reserved_words || [] } end end # This module adds the `:reserved_words` configuration option to # {FriendlyId::Configuration FriendlyId::Configuration}. module Configuration attr_accessor :reserved_words attr_accessor :treat_reserved_as_conflict end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
blacklight-spotlight-3.6.0.beta8 | vendor/bundle/ruby/3.2.0/gems/friendly_id-5.5.1/lib/friendly_id/reserved.rb |
friendly_id-5.5.1 | lib/friendly_id/reserved.rb |