ensl.org/app/models/custom_url.rb

33 lines
772 B
Ruby
Raw Normal View History

# == Schema Information
#
# Table name: custom_urls
#
# id :integer not null, primary key
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# article_id :integer
#
# Indexes
#
# index_custom_urls_on_article_id (article_id)
# index_custom_urls_on_name (name)
#
# FIXME: move this to a gem
class CustomUrl < ActiveRecord::Base
2020-03-26 02:26:30 +00:00
belongs_to :article, :optional => true
2020-03-17 01:03:02 +00:00
# FIXME: attr_accessible :name
2017-11-09 17:25:52 +00:00
validates :name,
length: {in: 2..10},
uniqueness: true,
2017-11-12 00:26:00 +00:00
format: /\A[a-z]+([\-])?[a-z]+\Z/
validates :article_id,
presence: true
def self.params(params, cuser)
params.require(:custom_url).permit(:name, :article_id)
end
end