Beginning Rails 4

3rd Edition

By Adam Gamble , Cloves Carneiro Jr , Rida Al Barazi

Beginning Rails 4 is a book that will guide you from never having programmed with Ruby, to having a Rails application built and deployed to the web. You’ll learn how to combine all the components of Rails to develop your own web applications. You will use test driven development to make sure your application works exactly like you expect.

Full Description

  • ISBN13: 978-1-4302-6034-9
  • 328 Pages
  • User Level: Beginner
  • Publication Date: September 17, 2013
  • Available eBook Formats: EPUB, MOBI, PDF
  • Print Book Price: $49.99
  • eBook Price: $34.99
Buy eBook Buy Print Book Add to Wishlist

Related Titles

Full Description

Beginning Rails 4 is a book that will guide you from never having programmed with Ruby, to having a Rails application built and deployed to the web. You’ll learn how to combine all the components of Rails to develop your own web applications. You will use test driven development to make sure your application works exactly like you expect.

You will learn how to use Git for source control and best practice techniques to create applications like a pro. Essential, and often-missed, information on testing and learning to program with Ruby are also covered.

This book is well suited for someone with little to no Ruby or Rails experience, or possibly even someone with no experience developing web applications at all. Beginning Rails 4 does assume a basic familiarity with the web and typical web terms, but doesn’t require you to be an expert of these. This book will springboard your journey into web application development, and show you how much fun building web applications with Ruby on Rails can be.
  • Learn to create Rails applications from the bottom up
  • Learn the basics of the Ruby programming language
  • Completely updated for Rails 4, including new information on turbo links, etc.

Beginning Rails 4 gently guides you through designing your application, writing tests for the application, and then writing the code to make your application work as expected.

What you’ll learn

  • Learn the basics of the Ruby programming language
  • Learn the components of Rails, and how to leverage them to build rich web applications
  • Build a good foundation so you can move on to more advanced techniques
  • Learn the basics of databases and how to use them to store and retrieve your data
  • Use git source control and contribute to open source on Github
  • Deploy your application to the web so others can use it

Who this book is for

Beginning Rails 4 is for anyone who wants to learn to quickly build applications, and deploy them to the web. No matter your experience level you’ll learn something from this book.

Table of Contents

Table of Contents

  1. Introducing the Rails Framework
  2. Getting Started
  3. Getting Something Running
  4. Introduction to the Ruby Language
  5. Working with a Database: Active Record
  6. Advanced Active Record: Enhancing Your Models
  7. Action Pack: Working with the View and the Controller
  8. Advanced Action Pack
  9. JavaScript and CSS
  10. Sending and Receiving Email
  11. Testing Your Application
  12. Internationalization
  13. Deploying Your Rails Applications
  14. Appendix A: Databases 101
  15. Appendix B: The Rails Community
  16. Appendix C: Git
Source Code/Downloads

Downloads are available to accompany this book.

Your operating system can likely extract zipped downloads automatically, but you may require software such as WinZip for PC, or StuffIt on a Mac.

Errata

Please Login to submit errata.

On page 20:
Mid-page, the folder structure illustrated is not the one generated by Rails (as claimed).

The following directories/files are missing in the book: bin, Gemfile.lock

The following directories are not present in the generated content (but should be according to the book): doc

There's also a minor inconsistency; the README file is shown with no extension in the book, but in reality it has an .rdoc extension.

A last point; the sorting is inconsistent. I would prefer having folders sorted by themselves followed/preceded by files sorted by themselves or just sorting everything from a to z. The current sorting has no real order. For example 'README' is presented before 'Rakefile' which in turn is presented before 'app'.

On page 20:
$ bundle install
--
Running 'bundle install' after 'rails new' is not necessary with Rails version 4. Rails does it automatically as confirmed by the output from Rails:
$ rails new hello
...
create vendor/assets/stylesheets/.keep
run bundle install

On page 29:
According to the text just above Listing 3.1 comments should be omitted in the listing. However, the database.yml file shown in the book is identical to the one generated by Rails, including the comments.

On page 31:
Line 5:
"Go ahead and create two more databases, one each for the test and production environments"
$ rake db:create:all

This incorrectly establishes that db:create:all creates TWO new databases that the previously executed 'rake db:create' did not create. However, 'rake db:create' creates both development and test databases, thus 'rake db:create:all' will only create ONE new database here; the production database.


On page 37:
Line 5:
"Notice that every time you add an article, you're redirected back to the index action.."

Not true. The generated Rails controller redirects to the 'show' action; that is, the page to show the one article that has been entered. From there you have to manually click "back" to get to the index.

On page 78:
Under Note section, Model.delete topic:

Model.delete(1,2,3) does not necessarily result into an error. If the first :id in the argument exist(:id => 1), Active Record will delete it and will just ignore the remaining ones (2,3).

On page 80:
article.errors.messages(:title) should be
article.errors.messages[:title], as the former returns an ArgumentError.

On page 96:
figure 6-4

shows "categories_articles", but according to the text above it should be "articles_categories".

On page 113:
when trying to create comment (p. 113) I get an error "ArgumentError: the provided regular expression is using mulitilen anchors (^ or $), which may present a security risk. Did you mean to use \A and \z, or forgot to add the :multiline => true option?

Fix: change listing 6-26, p. 111 use \A and \z instead ie
validates_format_of :email, :with => /\A[^@][\w.-]+@[\w.-]+[.]+[a-z]{2,4}\z/i