Sha256: 45f57155920d8505007795dc106fc53093172c622b96ca5c106fcc16a6140245
Contents?: true
Size: 773 Bytes
Versions: 1
Compression:
Stored size: 773 Bytes
Contents
module Blacksand class Navigation < ActiveRecord::Base belongs_to :page, required: false # ActiveRecord attribute api changed, see http://api.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html#method-i-attribute if ActiveRecord::VERSION::MAJOR >= 5 attribute :options, :json_type else attribute :options, MyJsonType.new end validates :name, presence: true validates :url, format: {with: URI.regexp}, if: Proc.new { |a| a.url.present? } validate :url_or_page_presence def url_or_page_presence if url.blank? && page_id.blank? errors.add(:url, "链接或者页面两个必须要填一项") errors.add(:page_id, "链接或者页面两个必须要填一项") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
blacksand-2.5.0 | app/models/blacksand/navigation.rb |