Commit 7a06d64f

mo k <mo@mokhan.ca>
2012-05-26 13:50:22
add interests database migrations and model.
1 parent fad62a7
app/models/interest.rb
@@ -0,0 +1,3 @@
+class Interest < ActiveRecord::Base
+  attr_accessible :name
+end
app/models/user.rb
@@ -13,6 +13,7 @@ class User < ActiveRecord::Base
   validates :website, :format => URI::regexp(%w(http https)), :allow_blank => true
   #validates_with UrlValidation
   has_many :authentications
+  has_many :interests
   devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
   attr_accessible :name, :email, :website, :twitter, :facebook, :password, :password_confirmation, :remember_me
   has_many :creations, :dependent => :destroy
db/migrate/20120526134044_create_interests.rb
@@ -0,0 +1,9 @@
+class CreateInterests < ActiveRecord::Migration
+  def change
+    create_table :interests do |t|
+      t.string :name
+
+      t.timestamps
+    end
+  end
+end
db/migrate/20120526134612_create_users_interests_join_table.rb
@@ -0,0 +1,11 @@
+class CreateUsersInterestsJoinTable < ActiveRecord::Migration
+  def up
+    create_table :users_interests, :id => false do |t|
+      t.integer :user_id
+      t.integer :interest_id
+    end
+  end
+
+  def down
+  end
+end
db/schema.rb
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20120522060801) do
+ActiveRecord::Schema.define(:version => 20120526134612) do
 
   create_table "active_admin_comments", :force => true do |t|
     t.integer  "resource_id",   :null => false
@@ -74,6 +74,12 @@ ActiveRecord::Schema.define(:version => 20120522060801) do
     t.datetime "updated_at",  :null => false
   end
 
+  create_table "interests", :force => true do |t|
+    t.string   "name"
+    t.datetime "created_at", :null => false
+    t.datetime "updated_at", :null => false
+  end
+
   create_table "photos", :force => true do |t|
     t.integer  "creation_id"
     t.string   "image"
@@ -103,4 +109,9 @@ ActiveRecord::Schema.define(:version => 20120522060801) do
   add_index "users", ["email"], :name => "index_users_on_email", :unique => true
   add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
 
+  create_table "users_interests", :id => false, :force => true do |t|
+    t.integer "user_id"
+    t.integer "interest_id"
+  end
+
 end
spec/models/interest_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Interest do
+  pending "add some examples to (or delete) #{__FILE__}"
+end