Ruby on Rails Tutorial

Ruby on Rails Tutorial

Ruby on Rails Tutorial
Автор: Hartl Michael
Дата выхода: 2015
Издательство: Independent publishing
Количество страниц: 915
Размер файла: 7,0 МБ
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

From zero to deploy
Up and running
Development environment
Installing Rails
The first application
Bundler
rails server
Model-View-Controller (MVC)
Hello, world!
Version control with Git
Installation and setup
What good does Git do you?
GitHub
Branch, edit, commit, merge
Deploying
Heroku setup and deployment
Heroku commands
Conclusion
What we learned in this chapter
Conventions used in this book
A toy app
Planning the application
A toy model for users
A toy model for microposts
The Users resource
A user tour
MVC in action
Weaknesses of this Users resource
The Microposts resource
A micropost microtour
Putting the micro in microposts
A user has_many microposts
Inheritance hierarchies
Deploying the toy app
Conclusion
What we learned in this chapter
Mostly static pages
Sample app setup
Static pages
Generated static pages
Custom static pages
Getting started with testing
Our first test
Red
Green
Refactor
Slightly dynamic pages
Testing titles (Red)
Adding page titles (Green)
Layouts and embedded Ruby (Refactor)
Setting the root route
Conclusion
What we learned in this chapter
Advanced testing setup
minitest reporters
Automated tests with Guard
Rails-flavored Ruby
Motivation
Built-in helpers
Custom helpers
Strings and methods
Strings
Objects and message passing
Method definitions
Back to the title helper
Other data structures
Arrays and ranges
Blocks
Hashes and symbols
CSS revisited
Ruby classes
Constructors
Class inheritance
Modifying built-in classes
A controller class
A user class
Conclusion
What we learned in this chapter
Filling in the layout
Adding some structure
Site navigation
Bootstrap and custom CSS
Partials
Sass and the asset pipeline
The asset pipeline
Syntactically awesome stylesheets
Layout links
Contact page
Rails routes
Using named routes
Layout link tests
User signup: A first step
Users controller
Signup URL
Conclusion
What we learned in this chapter
Modeling users
User model
Database migrations
The model file
Creating user objects
Finding user objects
Updating user objects
User validations
A validity test
Validating presence
Length validation
Format validation
Uniqueness validation
Adding a secure password
A hashed password
User has secure password
Minimum password standards
Creating and authenticating a user
Conclusion
What we learned in this chapter
Sign up
Showing users
Debug and Rails environments
A Users resource
Debugger
A Gravatar image and a sidebar
Signup form
Using form_with
Signup form HTML
Unsuccessful signups
A working form
Strong parameters
Signup error messages
A test for invalid submission
Successful signups
The finished signup form
The flash
The first signup
A test for valid submission
Professional-grade deployment
SSL in production
Production webserver
Production database configuration
Production deployment
Conclusion
What we learned in this chapter
Basic login
Sessions
Sessions controller
Login form
Finding and authenticating a user
Rendering with a flash message
A flash test
Logging in
The log_in method
Current user
Changing the layout links
Testing layout changes
Login upon signup
Logging out
Conclusion
What we learned in this chapter
Advanced login
Remember me
Remember token and digest
Login with remembering
Forgetting users
Two subtle bugs
``Remember me'' checkbox
Remember tests
Testing the ``remember me'' box
Testing the remember branch
Conclusion
What we learned in this chapter
Updating, showing, and deleting users
Updating users
Edit form
Unsuccessful edits
Testing unsuccessful edits
Successful edits (with TDD)
Authorization
Requiring logged-in users
Requiring the right user
Friendly forwarding
Showing all users
Users index
Sample users
Pagination
Users index test
Partial refactoring
Deleting users
Administrative users
The destroy action
User destroy tests
Conclusion
What we learned in this chapter
Account activation
Account activations resource
Account activations controller
Account activation data model
Account activation emails
Mailer templates
Email previews
Email tests
Updating the Users create action
Activating the account
Generalizing the authenticated? method
Activation edit action
Activation test and refactoring
Email in production
Conclusion
What we learned in this chapter
Password reset
Password resets resource
Password resets controller
New password resets
Password reset create action
Password reset emails
Password reset mailer and templates
Email tests
Resetting the password
Reset edit action
Updating the reset
Password reset test
Email in production (take two)
Conclusion
What we learned in this chapter
Proof of expiration comparison
User microposts
A Micropost model
The basic model
Micropost validations
User/Micropost associations
Micropost refinements
Showing microposts
Rendering microposts
Sample microposts
Profile micropost tests
Manipulating microposts
Micropost access control
Creating microposts
A proto-feed
Destroying microposts
Micropost tests
Micropost images
Basic image upload
Image validation
Image resizing
Image upload in production
Conclusion
What we learned in this chapter
Following users
The Relationship model
A problem with the data model (and a solution)
User/relationship associations
Relationship validations
Followed users
Followers
A web interface for following users
Sample following data
Stats and a follow form
Following and followers pages
A working follow button the standard way
A working follow button with Ajax
Following tests
The status feed
Motivation and strategy
A first feed implementation
Subselects
Conclusion
Guide to further resources
What we learned in this chapter

Ruby on Rails is one of the most popular web application development frameworks, but learning and using it is not the easiest task. This book will help you solve it, regardless of whether you have experience in web development in general and Rails in particular. The famous author and lead developer of Rails, Michael Hartl, will introduce you to Rails using the example of developing three applications. The author talks not only about Rails, but also describes the basics of Ruby, HTML, CSS and SQL, which will be useful to you when developing your web applications. Starting the discussion of each new technique, Hartl clearly explains how it helps to solve practical problems, and then demonstrates its application in a program code that is quite simple and understandable.

The publication is intended for all programmers who want to learn Ruby on Rails.


Похожее:

Список отзывов:

Нет отзывов к книге.