adds Settings

This commit is contained in:
Juanjo Bazán
2015-08-17 18:13:30 +02:00
parent fabcb42328
commit a13f4920a1
3 changed files with 21 additions and 1 deletions

7
app/models/setting.rb Normal file
View File

@@ -0,0 +1,7 @@
class Setting < ActiveRecord::Base
default_scope { order(key: :desc) }
def self.value_for(key)
where(key: key).pluck(:value).first
end
end

View File

@@ -0,0 +1,8 @@
class AddSettings < ActiveRecord::Migration
def change
create_table :settings do |t|
t.string :key
t.string :value
end
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150815154430) do
ActiveRecord::Schema.define(version: 20150817150457) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -59,6 +59,11 @@ ActiveRecord::Schema.define(version: 20150815154430) do
add_index "moderators", ["user_id"], name: "index_moderators_on_user_id", using: :btree
create_table "settings", force: :cascade do |t|
t.string "key"
t.string "value"
end
create_table "simple_captcha_data", force: :cascade do |t|
t.string "key", limit: 40
t.string "value", limit: 6