3 ms·
> validates :name, :login, :email, presence: true`. And prefer to write them explicit and unambiguous: `validates_presence_of(:name) etc`. Which is only a very
by Mikeb85 5y ago
> validates :name, :login, :email, presence: true`. And prefer to write them explicit and unambiguous: `validates_presence_of(:name) etc`. Which is only a very slightly improvement over `validates_presence_of('name')`.
That's Rails, not Ruby. Although Ruby allows it because of how flexible it is + metaprogramming.
- berkes 5y agoIt indeed is convention in Rails. A bad convention IMO. But it is enabled by Ruby, as you state, by how flexible Ruby is. It may seem a nice touch that Ruby hands you the freedom to choose to e.g. omit brackets. But I think this is a bad freedom. As Rails shows, its a freedom that leads to, IMO, harder to read, and harder to reason about code. With any language design, the limitations as well as its features, is what make the language. Limitations are an important feature of a language, IMO.