aboutsummaryrefslogtreecommitdiff
path: root/interfaces/ruby/models/config.rb
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-03-03 14:36:03 +0100
committerJohn Ankarström <john@ankarstrom.se>2021-03-03 14:36:03 +0100
commit27067b4d8e5e854f16e3bdb08c2f63f4250632a8 (patch)
tree3221635a1fda3604da02548debfab19b96ddd50c /interfaces/ruby/models/config.rb
parentd40c681d2f9d56e01cd5f1ff3e586b79ea4397f9 (diff)
downloadcomb-27067b4d8e5e854f16e3bdb08c2f63f4250632a8.tar.gz
Add 'url' field to config table
Diffstat (limited to 'interfaces/ruby/models/config.rb')
-rw-r--r--interfaces/ruby/models/config.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/interfaces/ruby/models/config.rb b/interfaces/ruby/models/config.rb
index 55b4106..007dbb3 100644
--- a/interfaces/ruby/models/config.rb
+++ b/interfaces/ruby/models/config.rb
@@ -1,17 +1,27 @@
class Config < ActiveRecord::Base
self.table_name = 'config'
+ before_validation :normalize_url
+ validates_presence_of :url
validates_presence_of :title
validates_presence_of :timezone
- validates_presence_of :postsperpage
+ validates_presence_of :posts_per_page
+
+private
+
+ def normalize_url
+ url.strip!
+ url.sub! /\/$/, ''
+ end
end
class CreateConfigTable < ActiveRecord::Migration[6.0]
def change
create_table :config do |t|
+ t.string :url, null: false
t.string :title, null: false
t.string :subtitle
t.string :timezone, null: false
- t.integer :postsperpage, null: false
+ t.integer :posts_per_page, null: false, default: 15
end
end
end