Permalink
Browse files

schema

  • Loading branch information...
1 parent 3a73762 commit 87bb98900a859e922af42e398bf29263db61023e Matt Hodgson committed May 21, 2009
@@ -5,10 +5,10 @@ class UsersController < ApplicationController
def new
@user = User.new
end
-
+
def create
@user = User.new(params[:user])
-
+
@user.save do |result|
if result
flash[:notice] = "Account registered!"
@@ -19,11 +19,11 @@ def create
end
end
-
+
def show
@user = @current_user
end
-
+
def edit
@user = @current_user
end
@@ -0,0 +1,5 @@
+class Occurrence < ActiveRecord::Base
+
+ has_many :topics, :through => :topics_occurrences
+
+end
@@ -0,0 +1,5 @@
+class Property < ActiveRecord::Base
+
+ belongs_to :topic
+
+end
@@ -0,0 +1,5 @@
+class PropertyType < ActiveRecord::Base
+
+ belongs_to :topic
+
+end
View
@@ -0,0 +1,9 @@
+class Topic < ActiveRecord::Base
+
+ has_many :properties
+ has_many :property_types
+ has_and_belongs_to_many :tags, :class_name => 'Topic', :join_table => :topics_topics, :foreign_key => :child_id, :association_foreign_key => :parent_id
+ has_and_belongs_to_many :topics, :class_name => 'Topic', :join_table => :topics_topics, :foreign_key => :parent_id, :association_foreign_key => :child_id
+ has_many :occurrences, :through => :topics_occurrences
+
+end
View
@@ -1,7 +1,9 @@
class User < ActiveRecord::Base
-
+
+ has_many :topics
+
acts_as_authentic do |c|
c.crypto_provider = Authlogic::CryptoProviders::BCrypt
end
-end
+end
@@ -0,0 +1,6 @@
+---
+mode: development
+port: 3001
+bundle: /Applications/Locomotive2/Bundles/rmagickRailsMar2007_i386.locobundle
+runs_at_launch: 0
+identifier: hippo-on-rails
@@ -17,4 +17,4 @@ def self.down
drop_table :open_id_authentication_associations
drop_table :open_id_authentication_nonces
end
-end
+end
@@ -0,0 +1,19 @@
+class CreateTopics < ActiveRecord::Migration
+ def self.up
+ create_table :topics do |t|
+ t.string :name
+ t.integer :user_id
+ t.timestamps
+ end
+
+ create_table :topics_topics, :id => false do |t|
+ t.integer :parent_id, :child_id
+ end
+ add_index :topics_topics, :parent_id
+ add_index :topics_topics, :child_id
+ end
+
+ def self.down
+ drop_table :topics
+ end
+end
@@ -0,0 +1,13 @@
+class CreateProperties < ActiveRecord::Migration
+ def self.up
+ create_table :properties do |t|
+ t.integer :topic_id, :property_type_id
+ t.text :value
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :properties
+ end
+end
@@ -0,0 +1,14 @@
+class CreateOccurrences < ActiveRecord::Migration
+ def self.up
+ create_table :occurrences do |t|
+ t.integer :topic_id
+ t.string :name
+ t.text :text
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :occurrences
+ end
+end
@@ -0,0 +1,13 @@
+class CreatePropertyTypes < ActiveRecord::Migration
+ def self.up
+ create_table :property_types do |t|
+ t.integer :topic_id
+ t.string :name, :type
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :property_types
+ end
+end
@@ -0,0 +1,19 @@
+class AddJoinTableForOccurrences < ActiveRecord::Migration
+ def self.up
+ change_table :occurrences do |t|
+ t.remove :topic_id
+ end
+
+ create_table :topics_occurrences do |t|
+ t.integer :topic_id, :occurrence_id
+ end
+ end
+
+ def self.down
+ change_table :occurrences do |t|
+ t.integer :topic_id
+ end
+
+ drop_table :topics_occurrences
+ end
+end
View
@@ -9,7 +9,14 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20090520224205) do
+ActiveRecord::Schema.define(:version => 20090521194112) do
+
+ create_table "occurrences", :force => true do |t|
+ t.string "name"
+ t.text "text"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
create_table "open_id_authentication_associations", :force => true do |t|
t.integer "issued"
@@ -21,13 +28,29 @@
end
create_table "open_id_authentication_nonces", :force => true do |t|
- t.integer "timestamp", :null => false
+ t.integer "timestamp", :null => false
t.string "server_url"
- t.string "salt", :null => false
+ t.string "salt", :default => "", :null => false
+ end
+
+ create_table "properties", :force => true do |t|
+ t.integer "topic_id"
+ t.integer "property_type_id"
+ t.text "value"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "property_types", :force => true do |t|
+ t.integer "topic_id"
+ t.string "name"
+ t.string "type"
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "sessions", :force => true do |t|
- t.string "session_id", :null => false
+ t.string "session_id", :default => "", :null => false
t.text "data"
t.datetime "created_at"
t.datetime "updated_at"
@@ -36,14 +59,34 @@
add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
+ create_table "topics", :force => true do |t|
+ t.string "name"
+ t.integer "user_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "topics_occurrences", :force => true do |t|
+ t.integer "topic_id"
+ t.integer "occurrence_id"
+ end
+
+ create_table "topics_topics", :id => false, :force => true do |t|
+ t.integer "parent_id"
+ t.integer "child_id"
+ end
+
+ add_index "topics_topics", ["child_id"], :name => "index_topics_topics_on_child_id"
+ add_index "topics_topics", ["parent_id"], :name => "index_topics_topics_on_parent_id"
+
create_table "users", :force => true do |t|
t.datetime "created_at"
t.datetime "updated_at"
t.string "login"
t.string "crypted_password"
t.string "password_salt"
- t.string "persistence_token", :null => false
- t.integer "login_count", :default => 0, :null => false
+ t.string "persistence_token", :default => "", :null => false
+ t.integer "login_count", :default => 0, :null => false
t.datetime "last_request_at"
t.datetime "last_login_at"
t.datetime "current_login_at"
Oops, something went wrong.

0 comments on commit 87bb989

Please sign in to comment.