Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add options table (key/value pairs) to db

  • Loading branch information...
commit 6a3f53d6a11ea9039b12ede990c2733d4147b830 1 parent f577081
@mnutt authored
View
11 app/models/option.rb
@@ -0,0 +1,11 @@
+class Option < ActiveRecord::Base
+ def self.get(key)
+ option = self.find_by_key(key.to_s)
+ option.value if option
+ end
+
+ def self.set(key, value)
+ option = self.find_or_create_by_key(key.to_s)
+ option.update_attributes(:value => value)
+ end
+end
View
14 db/migrate/20090330184414_create_options.rb
@@ -0,0 +1,14 @@
+class CreateOptions < ActiveRecord::Migration
+ def self.up
+ create_table :options do |t|
+ t.string :key
+ t.string :value
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :options
+ end
+end
View
9 db/schema.rb
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20090221080024) do
+ActiveRecord::Schema.define(:version => 20090330184414) do
create_table "dashboard_positions", :force => true do |t|
t.integer "column"
@@ -51,6 +51,13 @@
t.integer "is_rare"
end
+ create_table "options", :force => true do |t|
+ t.string "key"
+ t.string "value"
+ t.timestamp "created_at"
+ t.timestamp "updated_at"
+ end
+
create_table "playlists", :force => true do |t|
t.string "name"
t.integer "collaborative"
Please sign in to comment.
Something went wrong with that request. Please try again.