I've been doing Agile Development with Rails 4 which uses scaffolding in most parts of the book. However, I've read online that scaffolding in Rails is actually quite bad but I don't really understand why. Could anyone explain this to me? Thanks.
The name itself suggests using it for scaffolding. The use cases of it vary.
In Rails Tutorial by Michael Hartl it is used as a simple way of showing how to make Rails models work: what code is needed and where. Scaffolding demonstrates some of the basic elements just about any Rails developer uses in his apps, so it's at least a good starting point for beginners.
Once you are not a beginner, and you can write code comparable to scaffolding, you don't use it too often because it's just not suitable: you'll end up digging through the generated code and fixing it to suit your needs for longer than you would just write what you need from scratch. Otherwise you might accidentally expose private data, allow some restricted actions for everyone and who knows what else. It's easier to keep control of your code when it's filled in gradually. When you scaffold a model, a lot of uncontrolled code appears.
However, if you are not building an app yet, but more like researching how to build it (like testing out various DB schemas), scaffolding will speed up the process by bringing in an environment to construct and view data in your database in a convenient way so you can test whether your ideas will play well for your needs. Once you are done, you're likely to generate a new project and implement a more polished version from scratch.
There are also exotic uses you might find funny. With Rails you can also build apps that will never be shown in public but will rather be used internally. One of such cases is construction of a dataset for something. I have personally used it for a game, I scaffolded a certain in-game resource as a model and tweaked the way it outputs JSON index. Resources are filled in by everybody through convenient web interface, then exported to JSON file and put into into the game assets. This saves time, I only wasted like 15-20 minutes and saved us from hours of extra work on maintaining the dataset (structure always remains correct, data can be filled by several people in parallel).