Scraping a copy of a website for your own personal use is fine. (People used to do that all the time, back in the days of slow and unreliable modem connections; see http://en.wikipedia.org/wiki/Offline_reader .)

Scraping a copy of a website and then republishing it is different. Whether it's OK or not depends on the license under which the site is published:

- If no license is specified you should assume that the site's creator's retain complete copyright control of it, which means you'd need to ask them for permission before you could legally republish it. They can charge you any fee they wish for that permission, or require you to comply with any conditions they specify. You can negotiate with them on these points, but you'll need to get their approval before you can act, so they have the final say.

- Some sites are published under permissive licenses like the GNU Free Documentation License (http://www.gnu.org/copyleft/fdl.html) or the licenses provided by Creative Commons (http://creativecommons.org/licenses/). Sites that use these licenses will generally carry a notice to that effect somewhere. These licenses can allow you to republish stuff, as long as you follow the terms of the particular license; republishing a GFDL document would require you to make your republished version GFDL-licensed also, for instance, while republishing a document licensed under CC's Attribution license would let you republish as long as you include a credit to the site where the material first appeared. Check the particular license for the site you're looking at for complete details on what the terms are.

- Some online documents, like (for example) e-books from Project Gutenberg (http://www.gutenberg.org/) are just copies of material that has passed into the "public domain": see http://en.wikipedia.org/wiki/Public_domain. Public domain documents are documents on which the copyright has lapsed or expired. These can be republished in any way you wish without having to comply with any limitations or terms. Due to changes in copyright law, it is extremely rare to find documents published after the late 1920s in the public domain.

As noted above, unless the site explicitly says it's published under a particular license or is demonstrably in the public domain, you should assume it's not OK to republish anything from it without permission.

EDIT: In the specific case of the Rails tutorial you cited, the author helpfully spells out how the material is licensed, here: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book

> Ruby on Rails Tutorial: Learn Web Development with Rails. Copyright © 2013 by Michael Hartl. All source code in the Ruby on Rails Tutorial is available jointly under the MIT License and the Beerware License.

In other words: the text of the book itself is copyrighted, with the rightsholder being Michael Hartl. So you'd need his permission before you could republish/remix/whatever it. The source code of the coding examples, however, is published under the more permissive MIT and Beerware licenses. So you could republish that source code only without needing his formal permission, as long as you do so in a way that complies with one of those licenses.