Agile Web Development with Rails, Edition 5

8.4 Iteration C4: Functional Testing 8.2 Iteration C2: Add a Page Layout

8.3 Iteration C3: Use a Helper to Format the Price

Demonstrate helpers.

Format the price using a built-in helper.

edit app/views/store/index.html.erb
<% if notice %>
  <aside id="notice"><%= notice %></aside>
<% end %>
 
<h1>Your Pragmatic Catalog</h1>
 
<ul class="catalog">
  <% @products.each do |product| %>
    <li>
      <%= image_tag(product.image_url) %>
      <h2><%= product.title %></h2>
      <p>
        <%= sanitize(product.description) %>
      </p>
      <div class="price">
        <%= number_to_currency(product.price) %>
      </div>
    </li>
  <% end %>
</ul>

Show the results.

get /
The Pragmatic Bookshelf

Your Pragmatic Catalog

  • Rails, Angular, Postgres, and Bootstrap

    Powerful, Effective, and Efficient Full-Stack Web Development As a Rails developer, you care about user experience and performance, but you also want simple and maintainable code. Achieve all that by embracing the full stack of web development, from styling with Bootstrap, building an interactive user interface with AngularJS, to storing data quickly and reliably in PostgreSQL. Take a holistic view of full-stack development to create usable, high-performing applications, and learn to use these technologies effectively in a Ruby on Rails environment.

    $45.00
  • Ruby Performance Optimization

    Why Ruby Is Slow, and How to Fix It You don’t have to accept slow Ruby or Rails performance. In this comprehensive guide to Ruby optimization, you’ll learn how to write faster Ruby code—but that’s just the beginning. See exactly what makes Ruby and Rails code slow, and how to fix it. Alex Dymo will guide you through perils of memory and CPU optimization, profiling, measuring, performance testing, garbage collection, and tuning. You’ll find that all those “hard” things aren’t so difficult after all, and your code will run orders of magnitude faster.

    $46.00
  • Seven Mobile Apps in Seven Weeks

    Native Apps, Multiple Platforms Answer the question “Can we build this for ALL the devices?” with a resounding YES. This book will help you get there with a real-world introduction to seven platforms, whether you’re new to mobile or an experienced developer needing to expand your options. Plus, you’ll find out which cross-platform solution makes the most sense for your needs.

    $26.00

8.4 Iteration C4: Functional Testing 8.2 Iteration C2: Add a Page Layout