Browse files

Merge pull request #1 from gmaccarone/master

User model and pages controller fix for stories a User is following.
  • Loading branch information...
2 parents 9f9d023 + 4aac021 commit e08de0b60d57017e5771cf9f98ad77503659ef2f @buethling buethling committed Sep 27, 2011
Showing with 76 additions and 71 deletions.
  1. +5 −0 Gemfile.lock
  2. +1 −1 app/controllers/pages_controller.rb
  3. +1 −1 app/models/user.rb
  4. +69 −69 db/schema.rb
View
5 Gemfile.lock
@@ -31,6 +31,7 @@ GEM
activesupport (3.1.0)
multi_json (~> 1.0)
arel (2.2.1)
+ bcrypt-ruby (3.0.1)
bcrypt-ruby (3.0.1-x86-mingw32)
builder (3.0.0)
coffee-rails (3.1.1)
@@ -58,7 +59,9 @@ GEM
treetop (~> 1.4.8)
mime-types (1.16)
multi_json (1.0.3)
+ nokogiri (1.5.0)
nokogiri (1.5.0-x86-mingw32)
+ pg (0.11.0)
pg (0.11.0-x86-mingw32)
polyglot (0.3.2)
rack (1.3.3)
@@ -111,6 +114,7 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (!= 1.3.0, ~> 1.1)
+ sqlite3 (1.3.4)
sqlite3 (1.3.4-x86-mingw32)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
@@ -130,6 +134,7 @@ GEM
will_paginate (3.0.0)
PLATFORMS
+ ruby
x86-mingw32
DEPENDENCIES
View
2 app/controllers/pages_controller.rb
@@ -3,7 +3,7 @@ def home
@title = "Home"
if signed_in?
@stories = current_user.stories.paginate(:page => params[:page], :per_page => 5)
- @joined_stories = @stories #Character.find_by_user_id(current_user)
+ @joined_stories = current_user.following.paginate(:page => params[:page], :per_page => 5)
end
end
View
2 app/models/user.rb
@@ -8,7 +8,7 @@ class User < ActiveRecord::Base
has_many :stories
has_many :phrases
has_many :characters, :dependent => :destroy
- has_many :following, :through => :characters, :source => :story_id
+ has_many :following, :through => :characters, :source => :story
email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
View
138 db/schema.rb
@@ -1,69 +1,69 @@
-# encoding: UTF-8
-# This file is auto-generated from the current state of the database. Instead
-# of editing this file, please use the migrations feature of Active Record to
-# incrementally modify your database, and then regenerate this schema definition.
-#
-# Note that this schema.rb definition is the authoritative source for your
-# database schema. If you need to create the application database on another
-# system, you should be using db:schema:load, not running all the migrations
-# from scratch. The latter is a flawed and unsustainable approach (the more migrations
-# you'll amass, the slower it'll run and the greater likelihood for issues).
-#
-# It's strongly recommended to check this file into your version control system.
-
-ActiveRecord::Schema.define(:version => 20110712165421) do
-
- create_table "characters", :force => true do |t|
- t.string "story_id"
- t.string "user_id"
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- add_index "characters", ["story_id"], :name => "index_characters_on_story_id"
- add_index "characters", ["user_id", "story_id"], :name => "index_characters_on_user_id_and_story_id", :unique => true
- add_index "characters", ["user_id"], :name => "index_characters_on_user_id"
-
- create_table "microposts", :force => true do |t|
- t.string "content"
- t.integer "user_id"
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- create_table "phrases", :force => true do |t|
- t.string "content"
- t.integer "user_id"
- t.integer "story_id"
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- add_index "phrases", ["story_id"], :name => "index_phrases_on_story_id"
-
- create_table "stories", :force => true do |t|
- t.integer "user_id"
- t.string "blurb"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "title"
- t.integer "character_count", :default => 5
- t.integer "turn"
- end
-
- add_index "stories", ["title"], :name => "index_stories_on_title"
- add_index "stories", ["user_id"], :name => "index_stories_on_user_id"
-
- create_table "users", :force => true do |t|
- t.string "name"
- t.string "email"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "encrypted_password"
- t.string "salt"
- t.boolean "admin", :default => false
- end
-
- add_index "users", ["email"], :name => "index_users_on_email", :unique => true
-
-end
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20110712165421) do
+
+ create_table "characters", :force => true do |t|
+ t.integer "story_id"
+ t.integer "user_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "characters", ["story_id"], :name => "index_characters_on_story_id"
+ add_index "characters", ["user_id", "story_id"], :name => "index_characters_on_user_id_and_story_id", :unique => true
+ add_index "characters", ["user_id"], :name => "index_characters_on_user_id"
+
+ create_table "microposts", :force => true do |t|
+ t.string "content"
+ t.integer "user_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "phrases", :force => true do |t|
+ t.string "content"
+ t.integer "user_id"
+ t.integer "story_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "phrases", ["story_id"], :name => "index_phrases_on_story_id"
+
+ create_table "stories", :force => true do |t|
+ t.integer "user_id"
+ t.string "blurb"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "title"
+ t.integer "character_count", :default => 5
+ t.integer "turn"
+ end
+
+ add_index "stories", ["title"], :name => "index_stories_on_title"
+ add_index "stories", ["user_id"], :name => "index_stories_on_user_id"
+
+ create_table "users", :force => true do |t|
+ t.string "name"
+ t.string "email"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "encrypted_password"
+ t.string "salt"
+ t.boolean "admin", :default => false
+ end
+
+ add_index "users", ["email"], :name => "index_users_on_email", :unique => true
+
+end

0 comments on commit e08de0b

Please sign in to comment.