Pages: 342 Published: June 2017 ISBN: 9781680502206
In Print
Rails, Angular, Postgres, and Bootstrap, Second Edition
Powerful, Effective, Efficient, Full-Stack Web Development
by David Bryant Copeland
Achieve awesome user experiences and performance with simple,
maintainable code! Embrace the full stack of web development, from
styling with Bootstrap, building an interactive user interface with
Angular 4, to storing data quickly and reliably in PostgreSQL. With this
fully revised new edition, take a holistic view of full-stack
development to create usable, high-performing applications with Rails
5.1.
Rails is a great tool for building web applications, but it’s not the
best at everything. Embrace the features built into your database. Learn
how to use front-end frameworks. Seize the power of the application
stack through Angular 4, Bootstrap, and PostgreSQL. When used together,
these powerful and easy-to-use tools will open you to a new world of
possibilities. This second edition is updated to cover Angular 4—a
completely reworked front-end framework—and dives into new Postgres
9.6 features such as UPSERT. Also new is Webpack coverage, to develop
the front-end code for your Rails application.
Create a usable and attractive login form using Bootstrap’s styles,
while ensuring the database table backing it is secure using Postgres'
check constraints. See how creating an advanced Postgres index for a
case-insensitive search speeds up your back end—enabling you to create
a dynamic user experience using Angular 4. Create reusable components
that bring Bootstrap and Angular together and effectively use
materialized views for caching within Postgres. Get your front end
working with Webpack, use Postgres’ features from migrations, and write
unit tests for all of it. All of this within Rails 5.1.
You’ll gain the confidence to work at every level of the application
stack, bringing the right solution to every problem.
This book covers Postgres 9.6, Rails 5.1, and Ruby 2.3. You should have
some experience with basic Rails concepts and a cursory understanding of
JavaScript, CSS, and SQL, but by no means need to be an expert. You’ll
learn how to install Postgres on your computer or use a free version of
it in the cloud.
*Updated for the latest Rails 5.1.1, Webpacker 2.0, and all the various updates in the JavaScript ecosystem.
*Although we aren’t using TypeScript, the book now uses Webpacker’s Angular support to set up the entire tool chain to compile TypeScript. You’ll write code in .ts, so if you want to switch, you can. The downloadable code also creates a final version with all the JavaScript converted to TypeScript if you want to see what that’s like.
*CSS is now handled differently—and better. Before, we were using Webpack to insert style tags into our markup, live. Now, we’re using Webpacker’s configuration to generate an actual .css, which is more like what Sprockets does, and more like what you’d want in a real production application.
*We removed the Angular test app, as Webpacker provides enough scaffolding for us to validate the configuration. This means you can go straight to coding the app.
*We changed the JavaScript module style to use the more modern import (instead of require). import is how the latest versions of JavaScript will work, so this should age better and be more idiomatic.
*We removed the bits about running Webpack’s dev server in tests. Rails 5.1 wants developers to either run Webpack manually, or have it run once before tests are run. We’re doing the latter. This isn’t a perfect workflow, but it’s simpler and one less thing to have to wrestle with when getting this stuff going. This workflow does allow you to avoid running Webpack for unit tests, whereas the previous version would run it every time.
*The code examples are now organized in a better way.
*The book is finished in production and heading to layout.
2017/04/07
B6.0
* Updated to reference Angular 4 instead of Angular 2. Despite the drastic
version number change, not much really changed for us, and all the
examples still work. Also, there aren’t any relevant new features we need
to worry about.
* With the upcoming release of Rails 5.1, all the JavaScript got way better
due to…Webpacker! This makes initial set up much simpler and more
canonical.
* Unit tests are now run via Karma, which uses Webpack during tests. This
means no more proxyquire, and overall the tests are way simpler.
* Due to Webpacker, the locations of various files have changed. No more
webpack/ top-level directory. Everything is now the official Rails way of
doing things.
* We addressed some confusion around how the materialized views interact
with tests.
* We changed how we interact with Yarn and
package.json by preferring the
use of the
yarn add command over hand-editing the file.
2017/01/18
B5.0
The book is content-complete and heading to production.