Contents

1 From zero to deploy

1.1 Up and running

1.1.1 Development environment

1.1.2 Installing Rails

1.2 The first application

1.2.1 Bundler

1.2.2 rails server

1.2.3 Model-View-Controller (MVC)

1.2.4 Hello, world!

1.3 Version control with Git

1.3.1 Installation and setup

1.3.2 What good does Git do you?

1.3.3 GitHub

1.3.4 Branch, edit, commit, merge

1.4 Deploying

1.4.1 Heroku setup and deployment

1.4.2 Heroku deployment, step one

1.4.3 Heroku commands

1.5 Conclusion

1.5.1 What we learned in this chapter

1.6 Conventions used in this book

2 A toy app

2.1 Planning the application

2.1.1 A toy model for users

2.1.2 A toy model for microposts

2.2 The Users resource

2.2.1 A user tour

2.2.2 MVC in action

2.2.3 Weaknesses of this Users resource

2.3 The Microposts resource

2.3.1 A micropost microtour

2.3.2 Putting the micro in microposts

2.3.3 A user has_many microposts

2.3.4 Inheritance hierarchies

2.3.5 Deploying the toy app

2.4 Conclusion

2.4.1 What we learned in this chapter

3 Mostly static pages

3.1 Sample app setup

3.2 Static pages

3.2.1 Generated static pages

3.2.2 Custom static pages

3.3 Getting started with testing

3.3.1 Our first test

3.3.2 Red

3.3.3 Green

3.3.4 Refactor

3.4 Slightly dynamic pages

3.4.1 Testing titles (Red)

3.4.2 Adding page titles (Green)

3.4.3 Layouts and embedded Ruby (Refactor)

3.4.4 Setting the root route

3.5 Conclusion

3.5.1 What we learned in this chapter

3.6 Advanced testing setup

3.6.1 minitest reporters

3.6.2 Automated tests with Guard

4 Rails-flavored Ruby

4.1 Motivation

4.1.1 Built-in helpers

4.1.2 Custom helpers

4.2 Strings and methods

4.2.1 Strings

4.2.2 Objects and message passing

4.2.3 Method definitions

4.2.4 Back to the title helper

4.3 Other data structures

4.3.1 Arrays and ranges

4.3.2 Blocks

4.3.3 Hashes and symbols

4.3.4 CSS revisited

4.4 Ruby classes

4.4.1 Constructors

4.4.2 Class inheritance

4.4.3 Modifying built-in classes

4.4.4 A controller class

4.4.5 A user class

4.5 Conclusion

4.5.1 What we learned in this chapter

5 Filling in the layout

5.1 Adding some structure

5.1.1 Site navigation

5.1.2 Bootstrap and custom CSS

5.1.3 Partials

5.2 Sass and the asset pipeline

5.2.1 The asset pipeline

5.2.2 Syntactically awesome stylesheets

5.3 Layout links

5.3.1 Contact page

5.3.2 Rails routes

5.3.3 Using named routes

5.3.4 Layout link tests

5.4 User signup: A first step

5.4.1 Users controller

5.4.2 Signup URL

5.5 Conclusion

5.5.1 What we learned in this chapter

6 Modeling users

6.1 User model

6.1.1 Database migrations

6.1.2 The model file

6.1.3 Creating user objects

6.1.4 Finding user objects

6.1.5 Updating user objects

6.2 User validations

6.2.1 A validity test

6.2.2 Validating presence

6.2.3 Length validation

6.2.4 Format validation

6.2.5 Uniqueness validation

6.3 Adding a secure password

6.3.1 A hashed password

6.3.2 User has secure password

6.3.3 Minimum password standards

6.3.4 Creating and authenticating a user

6.4 Conclusion

6.4.1 What we learned in this chapter

7 Sign up

7.1 Showing users

7.1.1 Debug and Rails environments

7.1.2 A Users resource

7.1.3 Debugger

7.1.4 A Gravatar image and a sidebar

7.2 Signup form

7.2.1 Using form_with

7.2.2 Signup form HTML

7.3 Unsuccessful signups

7.3.1 A working form

7.3.2 Strong parameters

7.3.3 Signup error messages

7.3.4 A test for invalid submission

7.4 Successful signups

7.4.1 The finished signup form

7.4.2 The flash

7.4.3 The first signup

7.4.4 A test for valid submission

7.5 Professional-grade deployment

7.5.1 SSL in production

7.5.2 Production webserver

7.5.3 Production database configuration

7.5.4 Production deployment

7.6 Conclusion

7.6.1 What we learned in this chapter

8 Basic login

8.1 Sessions

8.1.1 Sessions controller

8.1.2 Login form

8.1.3 Finding and authenticating a user

8.1.4 Rendering with a flash message

8.1.5 A flash test

8.2 Logging in

8.2.1 The log_in method

8.2.2 Current user

8.2.3 Changing the layout links

8.2.4 Testing layout changes

8.2.5 Login upon signup

8.3 Logging out

8.4 Conclusion

8.4.1 What we learned in this chapter

9 Advanced login

9.1 Remember me

9.1.1 Remember token and digest

9.1.2 Login with remembering

9.1.3 Forgetting users

9.1.4 Two subtle bugs

9.2 “Remember me” checkbox

9.3 Remember tests

9.3.1 Testing the “remember me” box

9.3.2 Testing the remember branch

9.4 Conclusion

9.4.1 What we learned in this chapter

10 Updating, showing, and deleting users

10.1 Updating users

10.1.1 Edit form

10.1.2 Unsuccessful edits

10.1.3 Testing unsuccessful edits

10.1.4 Successful edits (with TDD)

10.2 Authorization

10.2.1 Requiring logged-in users

10.2.2 Requiring the right user

10.2.3 Friendly forwarding

10.3 Showing all users

10.3.1 Users index

10.3.2 Sample users

10.3.3 Pagination

10.3.4 Users index test

10.3.5 Partial refactoring

10.4 Deleting users

10.4.1 Administrative users

10.4.2 The destroy action

10.4.3 User destroy tests

10.5 Conclusion

10.5.1 What we learned in this chapter

11 Account activation

11.1 Account activations resource

11.1.1 Account activations controller

11.1.2 Account activation data model

11.2 Account activation emails

11.2.1 Mailer templates

11.2.2 Email previews

11.2.3 Email tests

11.2.4 Updating the Users create action

11.3 Activating the account

11.3.1 Generalizing the authenticated? method

11.3.2 Activation edit action

11.3.3 Activation test and refactoring

11.4 Email in production

11.5 Conclusion

11.5.1 What we learned in this chapter

12 Password reset

12.1 Password resets resource

12.1.1 Password resets controller

12.1.2 New password resets

12.1.3 Password reset create action

12.2 Password reset emails

12.2.1 Password reset mailer and templates

12.2.2 Email tests

12.3 Resetting the password

12.3.1 Reset edit action

12.3.2 Updating the reset

12.3.3 Password reset test

12.4 Email in production (take two)

12.5 Conclusion

12.5.1 What we learned in this chapter

12.6 Proof of expiration comparison

13 User microposts

13.1 A Micropost model

13.1.1 The basic model

13.1.2 Micropost validations

13.1.3 User/Micropost associations

13.1.4 Micropost refinements

13.2 Showing microposts

13.2.1 Rendering microposts

13.2.2 Sample microposts

13.2.3 Profile micropost tests

13.3 Manipulating microposts

13.3.1 Micropost access control

13.3.2 Creating microposts

13.3.3 A proto-feed

13.3.4 Destroying microposts

13.3.5 Micropost tests

13.4 Micropost images

13.4.1 Basic image upload

13.4.2 Image validation

13.4.3 Image resizing

13.4.4 Image upload in production

13.5 Conclusion

13.5.1 What we learned in this chapter

14 Following users

14.1 The Relationship model

14.1.1 A problem with the data model (and a solution)

14.1.2 User/relationship associations

14.1.3 Relationship validations

14.1.4 Followed users

14.1.5 Followers

14.2 A web interface for following users

14.2.1 Sample following data

14.2.2 Stats and a follow form

14.2.3 Following and followers pages

14.2.4 A working follow button the standard way

14.2.5 A working follow button with Ajax

14.2.6 Following tests

14.3 The status feed

14.3.1 Motivation and strategy

14.3.2 A first feed implementation

14.3.3 Subselects

14.4 Conclusion

14.4.1 Guide to further resources

14.4.2 What we learned in this chapter

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.80.129.195