From 8a88e71b3cedf9374eea44b7b14d7a3be41b1a45 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 8 Oct 2014 11:50:44 -0400 Subject: [PATCH] FEATURE: permalinks lookup table can redirect to any arbitrary url --- app/models/permalink.rb | 19 +++++++++++++++++++ ...008152953_add_exernal_url_to_permalinks.rb | 5 +++++ 2 files changed, 24 insertions(+) create mode 100644 db/migrate/20141008152953_add_exernal_url_to_permalinks.rb diff --git a/app/models/permalink.rb b/app/models/permalink.rb index d0d06e1f0..a216814fc 100644 --- a/app/models/permalink.rb +++ b/app/models/permalink.rb @@ -13,9 +13,28 @@ class Permalink < ActiveRecord::Base end def target_url + return external_url if external_url return post.url if post return topic.relative_url if topic return category.url if category nil end end + +# == Schema Information +# +# Table name: permalinks +# +# id :integer not null, primary key +# url :string(1000) not null +# topic_id :integer +# post_id :integer +# category_id :integer +# created_at :datetime +# updated_at :datetime +# external_url :string(1000) +# +# Indexes +# +# index_permalinks_on_url (url) UNIQUE +# diff --git a/db/migrate/20141008152953_add_exernal_url_to_permalinks.rb b/db/migrate/20141008152953_add_exernal_url_to_permalinks.rb new file mode 100644 index 000000000..f0ec67837 --- /dev/null +++ b/db/migrate/20141008152953_add_exernal_url_to_permalinks.rb @@ -0,0 +1,5 @@ +class AddExernalUrlToPermalinks < ActiveRecord::Migration + def change + add_column :permalinks, :external_url, :string, limit: 1000 + end +end