Rails has a concept called ‘convention over configuration’. In theory, this means that, by following conventions, we can accomplish a lot of work, without having to spend very much time configuring very much at all. In practice, it means that, generally, it’s not obvious what’s happening, especially to a Rails newbie. This can be confusing, but it works through a concept called metaprogramming.
Metaprogramming means that, rather than creating a lot of boilerplate code, rails will follow general conventions to automatically create a lot of functionality for us, in the form of methods that are created at runtime, and so only exist in active memory, in a running Rails application. Usually, the way we discover them, is through painful experience. Perhaps we implement something that’s already been built for us, through metaprogramming, and eventually learn about it. Or we create a method that has already been created by Rails, and end up with weird errors, because some other area of Rails code is using that method.
In the next post, we’ll explore some of the methods Rails creates for us when we add a field to a model.