adds Settings
This commit is contained in:
7
app/models/setting.rb
Normal file
7
app/models/setting.rb
Normal 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
|
||||
8
db/migrate/20150817150457_add_settings.rb
Normal file
8
db/migrate/20150817150457_add_settings.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user