Refactoring js code move assets/javascript/*.js from .html.haml

```
$ git rm app/assets/javascripts/chat_rooms.js.coffee
$ vim app/assets/javascripts/chat_rooms.js
$ vim app/views/chat_rooms/room.html.haml
```
Be able to
Be able to delete user account

```
$ vim app/controllers/users_controller.rb
$ vim app/views/users/index.html.haml
$ vim config/routes.rb
```
Add validation user model

```
$ vim app/models/user.rb
```

- User.name's length is 20 or less than 20
- User.name is uniqueness
- password's length is 4 or greater than 4, and 20 or less than 20
Add index to user table name column

```
$ rails g migration AddIndexToUserName
$ bundle exec rake db:migrate
```
Password was secured

```
$ rails g migration AddPasswordDigestToUsers
$ vim db/migrate/20140605110149_add_password_digest_to_users.rb
$ bundle exec rake db:migrate
$ vim Gemfile
$ vim Gemfile.lock
$ vim app/controllers/users_controller.rb
$ vim app/models/user.rb
$ vim app/views/users/_form.html.haml
```
Be able to "sign in"

```
$ rails g migration AddRememberTokenToUsers
$ bundle exec rake db:migrate
$ vim app/controllers/application_controller.rb
$ vim app/controllers/user_sessions_controller.rb
$ vim app/helpers/user_sessions_helper.rb
$ vim app/models/user.rb
$ vim app/views/user_sessions/new.html.haml
$ vim app/views/users/index.html.haml
$ vim config/routes.rb
```

Usually, controller/*.rb can't use helper/*.rb's method.
So, we need to include helper on the Controller or ApplicationController.
Remove unnecessary files

```
$ git rm app/assets/javascripts/pusher.js.coffee
$ git rm app/assets/javascripts/users.js.coffee
$ git rm app/assets/stylesheets/chat_rooms.css.scss
$ git rm app/assets/stylesheets/pusher.css.scss
$ git rm app/assets/stylesheets/users.css.scss
```
Be able to "sign out"

```
$ vim app/controllers/user_sessions_controller.rb
$ vim app/helpers/user_sessions_helper.rb
$ vim app/views/users/index.html.haml
$ vim config/routes.rb
```
Redirect to "sign in" page when failed to sign in

```
$ vim app/controllers/user_sessions_controller.rb
```
Redirect to user's page when signed in

```
$ vim app/controllers/user_sessions_controller.rb
$ vim app/controllers/users_controller.rb
$ vim config/routes.rb
$ vim app/views/users/show.html.haml
```
Sign in is required to destroy user

```
$ vim app/controllers/user_sessions_controller.rb
$ vim app/controllers/users_controller.rb
$ vim app/helpers/user_sessions_helper.rb
```
Sign in is required to sign out

```
$ vim app/views/users/index.html.haml
```
Remove unnecessary files

```
$ git rm app/helpers/chat_rooms_helper.rb
$ git rm app/helpers/pusher_helper.rb
$ git rm app/helpers/users_helper.rb
```
User can't move other user's page

```
$ vim app/controllers/users_controller.rb
$ vim app/helpers/user_sessions_helper.rb
```

If try to move other user's page, user is redirected to self page.
User can't destroy other user. User can move to my page from users page

```
$ vim app/views/users/index.html.haml
$ vim app/views/users/show.html.haml
```

User can cancel the membership on my page.
User list is easy to see

```
$ vim app/views/users/index.html.haml
```
Prepare the sample data

```
$ vim db/seeds.rb
```
Usualy user can't to administrate

```
$ rails g migration AddAdminToUsers
$ bundle exec rake db:migrate
$ vim db/seeds.rb
$ bundle exec rake db:seed
$ vim app/views/users/index.html.haml
```
Redirect to the user's intended page when completed sign-in

```
$ vim app/controllers/users_controller.rb
$ vim app/helpers/user_sessions_helper.rb
```