2020-03-18 03:38:17 +00:00
|
|
|
# == 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
|
2017-11-09 19:57:05 +00:00
|
|
|
class CustomUrl < ActiveRecord::Base
|
2017-11-09 17:25:52 +00:00
|
|
|
belongs_to :article
|
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
|
2020-03-18 03:38:17 +00:00
|
|
|
|
|
|
|
def self.params(params, cuser)
|
|
|
|
params.require(:custom_url).permit(:name, :article_id)
|
|
|
|
end
|
|
|
|
end
|