app/models/phcscriptcdnpro/script/listing.rb in phcscriptcdnpro-73.1.0 vs app/models/phcscriptcdnpro/script/listing.rb in phcscriptcdnpro-74.0.0
- old
+ new
@@ -2,43 +2,38 @@
class Script::Listing < ApplicationRecord
# Clean URL Initialize
extend FriendlyId
- # Add Paper Trail
+ # Paper Trail Initialize
has_paper_trail :class_name => 'Phcscriptcdnpro::ListingVersions'
# Relationships
- has_many :urls, class_name: 'Phcscriptcdnpro::Script::Url'
+ has_many :urls, class_name: 'Phcscriptcdnpro::Script::Url', :dependent => :destroy
belongs_to :author, class_name: 'Phcscriptcdnpro::Script::Author'
belongs_to :licence, class_name: 'Phcscriptcdnpro::Script::Licence'
- # Validation for Form Fields
- validates :script_tittle,
- presence: true,
- length: { minimum: 3 }
+ # Form Fields Validation
+ validates :script_title,
+ presence: true
validates :script_description,
- presence: true,
- length: { minimum: 4 }
+ presence: true
validates :script_source,
- length: { minimum: 5 }
+ format: { with: URI::regexp(%w(http https)), message: "Please follow this URL format http or https://www.**********.com" }
- validates :script_website,
- length: { minimum: 5 }
+ validates :script_website,
+ format: { with: URI::regexp(%w(http https)), message: "Please follow this URL format http or https://www.**********.com" }
validates :script_github,
- length: { minimum: 5 }
+ format: { with: URI::regexp(%w(http https)), message: "Please follow this URL format http or https://www.**********.com" }
# Clean URL Define
- friendly_id :phcscriptcdnpro_listing_slug, use: [:slugged, :finders]
+ friendly_id :phc_nice_url_slug, use: [:slugged, :finders]
- # Define for Multiple Records
- def phcscriptcdnpro_listing_slug
- [
- [:script_tittle, :version]
- ]
+ def phc_nice_url_slug
+ [:script_title]
end
end
end