From f3630c421fed4836228d209fd2ee5d25d68d3db6 Mon Sep 17 00:00:00 2001
From: saltfactory <saltfactory@gmail.com>
Date: Tue, 19 Jan 2016 00:35:24 +0900
Subject: [PATCH] =?UTF-8?q?=EA=B2=8C=EC=8B=9C=ED=8C=90=20=EA=B4=80?=
 =?UTF-8?q?=EB=A6=AC=EC=9E=90=EB=A5=BC=20=EC=9C=84=ED=95=9C=20=EC=BB=A8?=
 =?UTF-8?q?=ED=85=90=EC=B8=A0=20ownership=EC=9D=84=20polymorphic=EC=9C=BC?=
 =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 rails/sshb/Gemfile.lock                            | 24 ++++-----
 rails/sshb/app/assets/javascripts/dashboard.js     |  2 +
 rails/sshb/app/assets/javascripts/users.js         |  2 +
 rails/sshb/app/assets/stylesheets/dashboard.scss   |  3 ++
 rails/sshb/app/controllers/articles_controller.rb  |  1 +
 rails/sshb/app/controllers/dashboard_controller.rb |  2 +
 .../controllers/users/registrations_controller.rb  |  4 --
 rails/sshb/app/controllers/users_controller.rb     |  8 +++
 rails/sshb/app/helpers/dashboard_helper.rb         |  2 +
 rails/sshb/app/helpers/users_helper.rb             |  2 +
 rails/sshb/app/models/board.rb                     |  5 +-
 rails/sshb/app/models/boards_owner.rb              |  5 --
 rails/sshb/app/models/ownership.rb                 |  4 ++
 rails/sshb/app/models/user.rb                      |  6 ++-
 rails/sshb/app/views/dashboard/index.html.erb      |  0
 rails/sshb/app/views/home/_header.html.erb         | 57 ----------------------
 rails/sshb/app/views/layouts/_header.html.erb      | 40 +++++++++++++++
 rails/sshb/app/views/layouts/application.html.erb  |  2 +-
 .../app/views/users/registrations/show.html.erb    |  5 +-
 rails/sshb/app/views/users/show.html.erb           |  0
 rails/sshb/config/environments/development.rb      | 14 +++++-
 rails/sshb/config/initializers/devise.rb           |  1 +
 rails/sshb/config/routes.rb                        | 14 ++++--
 .../migrate/20160107011130_create_boards_owners.rb | 10 ----
 .../db/migrate/20160118141512_create_ownerships.rb |  9 ++++
 rails/sshb/db/schema.rb                            | 17 +++----
 rails/sshb/db/seeds.rb                             | 22 ++++++---
 .../test/controllers/dashboard_controller_test.rb  |  7 +++
 .../sshb/test/controllers/users_controller_test.rb |  7 +++
 rails/sshb/test/fixtures/boards_owners.yml         |  6 ---
 rails/sshb/test/fixtures/ownerships.yml            | 11 +++++
 rails/sshb/test/models/boards_owner_test.rb        |  7 ---
 rails/sshb/test/models/ownership_test.rb           |  7 +++
 33 files changed, 176 insertions(+), 130 deletions(-)
 create mode 100644 rails/sshb/app/assets/javascripts/dashboard.js
 create mode 100644 rails/sshb/app/assets/javascripts/users.js
 create mode 100644 rails/sshb/app/assets/stylesheets/dashboard.scss
 create mode 100644 rails/sshb/app/controllers/dashboard_controller.rb
 create mode 100644 rails/sshb/app/controllers/users_controller.rb
 create mode 100644 rails/sshb/app/helpers/dashboard_helper.rb
 create mode 100644 rails/sshb/app/helpers/users_helper.rb
 delete mode 100644 rails/sshb/app/models/boards_owner.rb
 create mode 100644 rails/sshb/app/models/ownership.rb
 create mode 100644 rails/sshb/app/views/dashboard/index.html.erb
 delete mode 100644 rails/sshb/app/views/home/_header.html.erb
 create mode 100644 rails/sshb/app/views/layouts/_header.html.erb
 create mode 100644 rails/sshb/app/views/users/show.html.erb
 delete mode 100644 rails/sshb/db/migrate/20160107011130_create_boards_owners.rb
 create mode 100644 rails/sshb/db/migrate/20160118141512_create_ownerships.rb
 create mode 100644 rails/sshb/test/controllers/dashboard_controller_test.rb
 create mode 100644 rails/sshb/test/controllers/users_controller_test.rb
 delete mode 100644 rails/sshb/test/fixtures/boards_owners.yml
 create mode 100644 rails/sshb/test/fixtures/ownerships.yml
 delete mode 100644 rails/sshb/test/models/boards_owner_test.rb
 create mode 100644 rails/sshb/test/models/ownership_test.rb

diff --git a/rails/sshb/Gemfile.lock b/rails/sshb/Gemfile.lock
index 63981bd..9231926 100644
--- a/rails/sshb/Gemfile.lock
+++ b/rails/sshb/Gemfile.lock
@@ -37,7 +37,7 @@ GEM
       thread_safe (~> 0.3, >= 0.3.4)
       tzinfo (~> 1.1)
     arel (6.0.3)
-    autoprefixer-rails (6.2.3)
+    autoprefixer-rails (6.3.0)
       execjs
       json
     bcrypt (3.1.10)
@@ -50,7 +50,7 @@ GEM
     byebug (8.2.1)
     climate_control (0.0.3)
       activesupport (>= 3.0)
-    cocaine (0.5.7)
+    cocaine (0.5.8)
       climate_control (>= 0.0.3, < 1.0)
     coffee-rails (4.1.1)
       coffee-script (>= 2.2.0)
@@ -61,7 +61,7 @@ GEM
     coffee-script-source (1.10.0)
     concurrent-ruby (1.0.0)
     debug_inspector (0.0.2)
-    devise (3.5.2)
+    devise (3.5.3)
       bcrypt (~> 3.0)
       orm_adapter (~> 0.1)
       railties (>= 3.2.6, < 5)
@@ -78,7 +78,7 @@ GEM
     jbuilder (2.4.0)
       activesupport (>= 3.0.0, < 5.1)
       multi_json (~> 1.2)
-    jquery-rails (4.0.5)
+    jquery-rails (4.1.0)
       rails-dom-testing (~> 1.0)
       railties (>= 4.2.0)
       thor (>= 0.14, < 2.0)
@@ -98,13 +98,13 @@ GEM
     nokogiri (1.6.7.1)
       mini_portile2 (~> 2.0.0.rc2)
     orm_adapter (0.5.0)
-    paperclip (4.3.1)
+    paperclip (4.3.2)
       activemodel (>= 3.2.0)
       activesupport (>= 3.2.0)
       cocaine (~> 0.5.5)
       mime-types
       mimemagic (= 0.3.0)
-    paperclip-storage-ftp (1.2.6)
+    paperclip-storage-ftp (1.2.7)
       paperclip
     rack (1.6.4)
     rack-test (0.6.3)
@@ -133,12 +133,12 @@ GEM
       activesupport (= 4.2.5)
       rake (>= 0.8.7)
       thor (>= 0.18.1, < 2.0)
-    rake (10.4.2)
+    rake (10.5.0)
     rdoc (4.2.1)
       json (~> 1.4)
-    responders (2.1.0)
-      railties (>= 4.2.0, < 5)
-    sass (3.4.20)
+    responders (2.1.1)
+      railties (>= 4.2.0, < 5.1)
+    sass (3.4.21)
     sass-rails (5.0.4)
       railties (>= 4.0.0, < 5.0)
       sass (~> 3.1)
@@ -148,7 +148,7 @@ GEM
     sdoc (0.4.1)
       json (~> 1.7, >= 1.7.7)
       rdoc (~> 4.0)
-    spring (1.6.1)
+    spring (1.6.2)
     sprockets (3.5.2)
       concurrent-ruby (~> 1.0)
       rack (> 1, < 3)
@@ -167,7 +167,7 @@ GEM
     uglifier (2.7.2)
       execjs (>= 0.3.0)
       json (>= 1.8.0)
-    warden (1.2.3)
+    warden (1.2.4)
       rack (>= 1.0)
     web-console (2.2.1)
       activemodel (>= 4.0)
diff --git a/rails/sshb/app/assets/javascripts/dashboard.js b/rails/sshb/app/assets/javascripts/dashboard.js
new file mode 100644
index 0000000..dee720f
--- /dev/null
+++ b/rails/sshb/app/assets/javascripts/dashboard.js
@@ -0,0 +1,2 @@
+// Place all the behaviors and hooks related to the matching controller here.
+// All this logic will automatically be available in application.js.
diff --git a/rails/sshb/app/assets/javascripts/users.js b/rails/sshb/app/assets/javascripts/users.js
new file mode 100644
index 0000000..dee720f
--- /dev/null
+++ b/rails/sshb/app/assets/javascripts/users.js
@@ -0,0 +1,2 @@
+// Place all the behaviors and hooks related to the matching controller here.
+// All this logic will automatically be available in application.js.
diff --git a/rails/sshb/app/assets/stylesheets/dashboard.scss b/rails/sshb/app/assets/stylesheets/dashboard.scss
new file mode 100644
index 0000000..3a51a8c
--- /dev/null
+++ b/rails/sshb/app/assets/stylesheets/dashboard.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the dashboard controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/rails/sshb/app/controllers/articles_controller.rb b/rails/sshb/app/controllers/articles_controller.rb
index 9d0b7c1..a03bde1 100644
--- a/rails/sshb/app/controllers/articles_controller.rb
+++ b/rails/sshb/app/controllers/articles_controller.rb
@@ -2,6 +2,7 @@ class ArticlesController < ApplicationController
   before_action :set_article, only: [:show, :edit, :update, :destroy]
   before_action :set_board, only: [:index, :new, :edit, :create]
 
+  before_action :authenticate_user!, except: [:index, :show]
 
   # GET /articles
   # GET /articles.json
diff --git a/rails/sshb/app/controllers/dashboard_controller.rb b/rails/sshb/app/controllers/dashboard_controller.rb
new file mode 100644
index 0000000..e1192e4
--- /dev/null
+++ b/rails/sshb/app/controllers/dashboard_controller.rb
@@ -0,0 +1,2 @@
+class DashboardController < ApplicationController
+end
diff --git a/rails/sshb/app/controllers/users/registrations_controller.rb b/rails/sshb/app/controllers/users/registrations_controller.rb
index 3b76aab..5ca7479 100644
--- a/rails/sshb/app/controllers/users/registrations_controller.rb
+++ b/rails/sshb/app/controllers/users/registrations_controller.rb
@@ -2,10 +2,6 @@ class Users::RegistrationsController < Devise::RegistrationsController
 # before_filter :configure_sign_up_params, only: [:create]
 # before_filter :configure_account_update_params, only: [:update]
 
-  def show
-    @user = current_user
-  end
-
   # GET /resource/sign_up
   # def new
   #   super
diff --git a/rails/sshb/app/controllers/users_controller.rb b/rails/sshb/app/controllers/users_controller.rb
new file mode 100644
index 0000000..55cae75
--- /dev/null
+++ b/rails/sshb/app/controllers/users_controller.rb
@@ -0,0 +1,8 @@
+class UsersController < ApplicationController
+
+  before_action :authenticate_user!
+
+  def show
+    @user = current_user
+  end
+end
diff --git a/rails/sshb/app/helpers/dashboard_helper.rb b/rails/sshb/app/helpers/dashboard_helper.rb
new file mode 100644
index 0000000..a94ddfc
--- /dev/null
+++ b/rails/sshb/app/helpers/dashboard_helper.rb
@@ -0,0 +1,2 @@
+module DashboardHelper
+end
diff --git a/rails/sshb/app/helpers/users_helper.rb b/rails/sshb/app/helpers/users_helper.rb
new file mode 100644
index 0000000..2310a24
--- /dev/null
+++ b/rails/sshb/app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
+module UsersHelper
+end
diff --git a/rails/sshb/app/models/board.rb b/rails/sshb/app/models/board.rb
index 24f1a81..6b0c843 100644
--- a/rails/sshb/app/models/board.rb
+++ b/rails/sshb/app/models/board.rb
@@ -1,5 +1,8 @@
 class Board < ActiveRecord::Base
-  has_many :boards_owners, autosave: true, dependent: :destroy
+
+  has_many :owners, through: :ownerships, source: :user
+  has_many :ownerships, as: :ownerable
+
   has_many :articles
   # accepts_nested_attributes_for :boards_owners,
   #                               allow_destroy: true,
diff --git a/rails/sshb/app/models/boards_owner.rb b/rails/sshb/app/models/boards_owner.rb
deleted file mode 100644
index 6d50dca..0000000
--- a/rails/sshb/app/models/boards_owner.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class BoardsOwner < ActiveRecord::Base
-  belongs_to :board
-  belongs_to :user
-  belongs_to :role
-end
diff --git a/rails/sshb/app/models/ownership.rb b/rails/sshb/app/models/ownership.rb
new file mode 100644
index 0000000..54b3856
--- /dev/null
+++ b/rails/sshb/app/models/ownership.rb
@@ -0,0 +1,4 @@
+class Ownership < ActiveRecord::Base
+  belongs_to :user
+  belongs_to :ownerable, polymorphic: true
+end
diff --git a/rails/sshb/app/models/user.rb b/rails/sshb/app/models/user.rb
index ae870f5..9f878e9 100644
--- a/rails/sshb/app/models/user.rb
+++ b/rails/sshb/app/models/user.rb
@@ -6,14 +6,16 @@ class User < ActiveRecord::Base
 
   has_many :attachments, as: :owner
   has_many :photos, as: :attachable
-  has_one :photo, as: :attachable
+
 
   # has_many :avatars, through: :attachments, source: :attachable, source_type: 'User'
 
 
   # has_and_belongs_to_many :boards
   # has_many :boadrs, through: :boards_owners
-  has_many :boards_owners
+  has_many :boards, through: :ownerships, source: :ownerable, source_type: "Board"
+  has_many :ownerships
+
 
   before_create :set_default_role
 
diff --git a/rails/sshb/app/views/dashboard/index.html.erb b/rails/sshb/app/views/dashboard/index.html.erb
new file mode 100644
index 0000000..e69de29
diff --git a/rails/sshb/app/views/home/_header.html.erb b/rails/sshb/app/views/home/_header.html.erb
deleted file mode 100644
index 804c5f8..0000000
--- a/rails/sshb/app/views/home/_header.html.erb
+++ /dev/null
@@ -1,57 +0,0 @@
-<nav class="navbar navbar-default">
-  <div class="container-fluid">
-    <div class="navbar-header">
-      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
-        <span class="sr-only">Toggle navigation</span>
-        <span class="icon-bar"></span>
-        <span class="icon-bar"></span>
-        <span class="icon-bar"></span>
-      </button>
-      <a class="navbar-brand" href="#">성산한빛교회</a>
-    </div>
-    <div id="navbar" class="navbar-collapse collapse">
-      <!--<ul class="nav navbar-nav">-->
-        <!--<li class="active"><a href="#">Home</a></li>-->
-        <!--<li><a href="#">About</a></li>-->
-        <!--<li><a href="#">Contact</a></li>-->
-        <!--<li class="dropdown">-->
-          <!--<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown-->
-            <!--<span class="caret"></span></a>-->
-          <!--<ul class="dropdown-menu">-->
-            <!--<li><a href="#">Action</a></li>-->
-            <!--<li><a href="#">Another action</a></li>-->
-            <!--<li><a href="#">Something else here</a></li>-->
-            <!--<li role="separator" class="divider"></li>-->
-            <!--<li class="dropdown-header">Nav header</li>-->
-            <!--<li><a href="#">Separated link</a></li>-->
-            <!--<li><a href="#">One more separated link</a></li>-->
-          <!--</ul>-->
-        <!--</li>-->
-      <!--</ul>-->
-      <ul class="nav navbar-nav navbar-right">
-        <li class="active">
-          <%= link_to "홈", root_path %>
-        </li>
-        <li><%= link_to "교회소개", page_about_path %></li>
-        <li><%= link_to "교회소식", '/boards/notice' %></li>
-        <% if user_signed_in? %>
-          <li><%= link_to "내 정보", user_root_path %></li>
-          <li><%= link_to "로그아웃", destroy_user_session_path, method: :delete %></li>
-        <% else %>
-          <li><%= link_to "로그인", new_user_session_path %></li>
-          <li></li>
-      <% end %>
-        <!--<li><a href="../navbar-static-top/">Static top</a></li>-->
-        <!--<li><a href="../navbar-fixed-top/">Fixed top</a></li>-->
-      </ul>
-    </div><!--/.nav-collapse -->
-  </div><!--/.container-fluid -->
-</nav>
-
-
-<% if notice %>
-  <p class="alert alert-success"><%= notice %></p>
-<% end %>
-<% if alert %>
-  <p class="alert alert-danger"><%= alert %></p>
-<% end %>
diff --git a/rails/sshb/app/views/layouts/_header.html.erb b/rails/sshb/app/views/layouts/_header.html.erb
new file mode 100644
index 0000000..b233f89
--- /dev/null
+++ b/rails/sshb/app/views/layouts/_header.html.erb
@@ -0,0 +1,40 @@
+<nav class="navbar navbar-default">
+  <div class="container-fluid">
+    <div class="navbar-header">
+      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
+        <span class="sr-only">Toggle navigation</span>
+        <span class="icon-bar"></span>
+        <span class="icon-bar"></span>
+        <span class="icon-bar"></span>
+      </button>
+      <a class="navbar-brand" href="#">성산한빛교회</a>
+    </div>
+    <div id="navbar" class="navbar-collapse collapse">
+      <ul class="nav navbar-nav navbar-right">
+        <li class="active">
+          <%= link_to "홈", root_path %>
+        </li>
+        <li><%= link_to "교회소개", page_about_path %></li>
+        <li><%= link_to "설교말씀", '/boards/sermons' %></li>
+        <li><%= link_to "교회소식", '/boards/informs' %></li>
+        <% if user_signed_in? %>
+          <li><%= link_to "내 정보", profile_path %></li>
+          <li><%= link_to "로그아웃", destroy_user_session_path, method: :delete %></li>
+        <% else %>
+          <li><%= link_to "로그인", new_user_session_path %></li>
+          <li></li>
+      <% end %>
+        <!--<li><a href="../navbar-static-top/">Static top</a></li>-->
+        <!--<li><a href="../navbar-fixed-top/">Fixed top</a></li>-->
+      </ul>
+    </div><!--/.nav-collapse -->
+  </div><!--/.container-fluid -->
+</nav>
+
+
+<% if notice %>
+  <p class="alert alert-success"><%= notice %></p>
+<% end %>
+<% if alert %>
+  <p class="alert alert-danger"><%= alert %></p>
+<% end %>
diff --git a/rails/sshb/app/views/layouts/application.html.erb b/rails/sshb/app/views/layouts/application.html.erb
index 83053ad..c7b5004 100644
--- a/rails/sshb/app/views/layouts/application.html.erb
+++ b/rails/sshb/app/views/layouts/application.html.erb
@@ -21,7 +21,7 @@
 <body>
 
 
-<%= render "home/header" %>
+<%= render "layouts/header" %>
 <div class="container">
 <%= yield %>
 </div>
diff --git a/rails/sshb/app/views/users/registrations/show.html.erb b/rails/sshb/app/views/users/registrations/show.html.erb
index 6aca1f6..5c78ebf 100644
--- a/rails/sshb/app/views/users/registrations/show.html.erb
+++ b/rails/sshb/app/views/users/registrations/show.html.erb
@@ -1,12 +1,9 @@
 <div class="profile">
   <p class="text-center">
-    <%= image_tag resource.avatar, size: "100", class: ["img-circle", "img-responsive"] %>
+    <%= image_tag resource, size: "100", class: ["img-circle", "img-responsive"] %>
   </p>
 </div>
 
-
-
-
 <p>
   이메일(아이디) : <%= resource.email %>
 </p>
diff --git a/rails/sshb/app/views/users/show.html.erb b/rails/sshb/app/views/users/show.html.erb
new file mode 100644
index 0000000..e69de29
diff --git a/rails/sshb/config/environments/development.rb b/rails/sshb/config/environments/development.rb
index e9d8fdb..3286883 100644
--- a/rails/sshb/config/environments/development.rb
+++ b/rails/sshb/config/environments/development.rb
@@ -1,5 +1,7 @@
 Rails.application.configure do
   # Settings specified here will take precedence over those in config/application.rb.
+  secrets_file =  Rails.root.join('config', 'secrets.yml')
+  SECRETS = YAML::load_file(secrets_file)[Rails.env] rescue {}
 
   # In the development environment your application's code is reloaded on
   # every request. This slows down response time but is perfect for development
@@ -15,7 +17,17 @@
 
   # Don't care if the mailer can't send.
   config.action_mailer.raise_delivery_errors = false
-  config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
+  config.action_mailer.default_url_options = {:host => 'localhost:3000'}
+  config.action_mailer.delivery_method = :smtp
+  config.action_mailer.default :charset => "utf-8"
+  config.action_mailer.smtp_settings = {
+    :address => 'smtp.gmail.com',
+    :port => 587,
+    :authentication => :login,
+    :enable_startssl_auto => true,
+    :user_name => SECRETS['smtp_username'],
+    :password => SECRETS['smtp_password']
+  }
 
   # Print deprecation notices to the Rails logger.
   config.active_support.deprecation = :log
diff --git a/rails/sshb/config/initializers/devise.rb b/rails/sshb/config/initializers/devise.rb
index 25dbbbe..372497c 100644
--- a/rails/sshb/config/initializers/devise.rb
+++ b/rails/sshb/config/initializers/devise.rb
@@ -8,6 +8,7 @@
   # by default. You can change it below and use your own secret key.
   # config.secret_key = '6d615fc4a29b7ed3b3ea5650d389a7dab78b9ef9d39819f4859b98930e8c0f30c43ca7504a84fcb3e4b9311e66fa71ff4a8676999dd257122b2a18e6a31462bc'
 
+
   # ==> Mailer Configuration
   # Configure the e-mail address which will be shown in Devise::Mailer,
   # note that it will be overwritten if you use your own mailer class
diff --git a/rails/sshb/config/routes.rb b/rails/sshb/config/routes.rb
index 10d5026..dbdf979 100644
--- a/rails/sshb/config/routes.rb
+++ b/rails/sshb/config/routes.rb
@@ -3,7 +3,7 @@
   get 'page/welcome'
   get 'page/about'
 
-  devise_for :users
+
   # The priority is based upon order of creation: first created -> highest priority.
   # See how all your routes lay out with "rake routes".
 
@@ -11,15 +11,19 @@
   # root 'welcome#index'
   root 'home#index'
 
+  get '/dashboard' => 'dashboard#index'
+
   # match 'user/show' => 'users#show', via: 'get'
   # devise_for :users, controllers: {
   #   sessions: 'users/sessions'
   # }
+  devise_for :users
+  # devise_scope :user do
+  #   get 'users/profile', :to => 'users#show', :as => :user_root
+  # end
 
-  as :user do
-    get 'users/profile', :to => 'users/registrations#show', :as => :user_root
-  end
-
+  get '/profile' => 'users#show', as: "profile"
+  resources :users
 
 
   resources :attachments
diff --git a/rails/sshb/db/migrate/20160107011130_create_boards_owners.rb b/rails/sshb/db/migrate/20160107011130_create_boards_owners.rb
deleted file mode 100644
index 55907af..0000000
--- a/rails/sshb/db/migrate/20160107011130_create_boards_owners.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class CreateBoardsOwners < ActiveRecord::Migration
-  def change
-    create_table :boards_owners do |t|
-      t.belongs_to :board, index: true
-      t.belongs_to :role, index: true
-      t.belongs_to :user, index: true
-      t.timestamps null: false
-    end
-  end
-end
diff --git a/rails/sshb/db/migrate/20160118141512_create_ownerships.rb b/rails/sshb/db/migrate/20160118141512_create_ownerships.rb
new file mode 100644
index 0000000..8413627
--- /dev/null
+++ b/rails/sshb/db/migrate/20160118141512_create_ownerships.rb
@@ -0,0 +1,9 @@
+class CreateOwnerships < ActiveRecord::Migration
+  def change
+    create_table :ownerships do |t|
+      t.references :user, index: true, foreign_key: true
+      t.references :ownerable, polymorphic: true, index: true
+      t.timestamps null: false
+    end
+  end
+end
diff --git a/rails/sshb/db/schema.rb b/rails/sshb/db/schema.rb
index 368c56e..8454e40 100644
--- a/rails/sshb/db/schema.rb
+++ b/rails/sshb/db/schema.rb
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 20160108063459) do
+ActiveRecord::Schema.define(version: 20160118141512) do
 
   create_table "articles", force: :cascade do |t|
     t.string   "subject"
@@ -61,17 +61,16 @@
     t.datetime "updated_at",  null: false
   end
 
-  create_table "boards_owners", force: :cascade do |t|
-    t.integer  "board_id"
-    t.integer  "role_id"
+  create_table "ownerships", force: :cascade do |t|
     t.integer  "user_id"
-    t.datetime "created_at", null: false
-    t.datetime "updated_at", null: false
+    t.integer  "ownerable_id"
+    t.string   "ownerable_type"
+    t.datetime "created_at",     null: false
+    t.datetime "updated_at",     null: false
   end
 
-  add_index "boards_owners", ["board_id"], name: "index_boards_owners_on_board_id"
-  add_index "boards_owners", ["role_id"], name: "index_boards_owners_on_role_id"
-  add_index "boards_owners", ["user_id"], name: "index_boards_owners_on_user_id"
+  add_index "ownerships", ["ownerable_type", "ownerable_id"], name: "index_ownerships_on_ownerable_type_and_ownerable_id"
+  add_index "ownerships", ["user_id"], name: "index_ownerships_on_user_id"
 
   create_table "roles", force: :cascade do |t|
     t.string   "name"
diff --git a/rails/sshb/db/seeds.rb b/rails/sshb/db/seeds.rb
index 7696d15..352be3f 100644
--- a/rails/sshb/db/seeds.rb
+++ b/rails/sshb/db/seeds.rb
@@ -24,10 +24,20 @@
   user.avatar = "http://blog.saltfactory.net/assets/images/profile.jpeg"
 end
 
-['noticeboard'].each do |name|
-  Board.find_or_create_by({name: name, uuid: SecureRandom.uuid, slug: "notice" })
+['sermons', 'informs'].each do |name|
+  Board.find_or_create_by({name: name}) do |board|
+    board.uuid = SecureRandom.uuid
+    board.slug = name
+    board.owners << User.first
+  end
+end
+#
+# # BoardsOwner.find_or_create_by({user: User.first, board: Board.first, role: Role.find_by_name("admin")})
+#
+#
+Article.find_or_create_by({id: 1}) do |article|
+  article.author = User.first
+  article.board = Board.find_by_slug("informs")
+  article.subject = "test"
+  article.content = "test"
 end
-
-
-BoardsOwner.find_or_create_by({user: User.first, board: Board.first, role: Role.find_by_name("admin")})
-
diff --git a/rails/sshb/test/controllers/dashboard_controller_test.rb b/rails/sshb/test/controllers/dashboard_controller_test.rb
new file mode 100644
index 0000000..b72f3c0
--- /dev/null
+++ b/rails/sshb/test/controllers/dashboard_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class DashboardControllerTest < ActionController::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/rails/sshb/test/controllers/users_controller_test.rb b/rails/sshb/test/controllers/users_controller_test.rb
new file mode 100644
index 0000000..d23f182
--- /dev/null
+++ b/rails/sshb/test/controllers/users_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class UsersControllerTest < ActionController::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/rails/sshb/test/fixtures/boards_owners.yml b/rails/sshb/test/fixtures/boards_owners.yml
deleted file mode 100644
index 0bb3f52..0000000
--- a/rails/sshb/test/fixtures/boards_owners.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
-
-one:
-  board_id: 1
-  user_id: 1
-  role_id: 4
diff --git a/rails/sshb/test/fixtures/ownerships.yml b/rails/sshb/test/fixtures/ownerships.yml
new file mode 100644
index 0000000..dba5cb5
--- /dev/null
+++ b/rails/sshb/test/fixtures/ownerships.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+  user_id: 
+  ownerable_id: 
+  ownerable_type: Ownerable
+
+two:
+  user_id: 
+  ownerable_id: 
+  ownerable_type: Ownerable
diff --git a/rails/sshb/test/models/boards_owner_test.rb b/rails/sshb/test/models/boards_owner_test.rb
deleted file mode 100644
index fe01bb9..0000000
--- a/rails/sshb/test/models/boards_owner_test.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-require 'test_helper'
-
-class BoardsOwnerTest < ActiveSupport::TestCase
-  # test "the truth" do
-  #   assert true
-  # end
-end
diff --git a/rails/sshb/test/models/ownership_test.rb b/rails/sshb/test/models/ownership_test.rb
new file mode 100644
index 0000000..4ac93e1
--- /dev/null
+++ b/rails/sshb/test/models/ownership_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class OwnershipTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
