We cover:

  • Replacing Rails’ testing framework with RSpec
  • Using Slim for HTML templates instead of ERB
  • Serving CSS with Webpack
  • Post-processing CSS with cssnext

Chapter 23
Customizing and Extending Rails

As you’ve come to learn, Rails provides an answer for almost every question you have about building a modern web application. It provides the basics for handling requests, accessing a database, writing user interfaces, and running tests. It does this by having a tightly integrated design, which is often referred to as Rails being “opinionated software.”

This tight coupling comes at a price. If, for example, the way Rails manages CSS doesn’t meet the needs of your project, you could be in trouble. Or, if you prefer to write your tests in a different way, Rails doesn’t give you a lot of options. Or does it? In past versions of Rails, customizing it was difficult or impossible. In Rails 3, much effort was expended to make Rails more customizable, and by Rails 4, developers had a lot more flexibility to use the tools they prefer or that work the way they want to work. That’s what we’ll explore in this chapter.

We’ll replace three parts of Rails in this chapter. First, we’ll see how to use RSpec to write our tests instead of Rails’ default testing library. Next, we’ll replace ERB for the alternative templating language Slim. Finally, we’ll see how to manage CSS using Webpack instead of putting it in app/assets/stylesheets. This chapter will demonstrate another benefit to Rails, which is that you don’t have to throw out the parts that work for you to use alternatives that work better. Let’s get started.

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

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