4 ms·
Aren't your ActiveRecord models basically the only place in a Rails app where you do specify the types of your properties?
by favorited 8y ago
Aren't your ActiveRecord models basically the only place in a Rails app where you do specify the types of your properties?
- hombre_fatal 8y agoI'm referring to things like dynamic find_by_* messages since more people might be familiar with that. But I don't know why you'd say that. ActiveRecord models are one of the main places you'll see a bunch of `use SomeGem::Thing` that introduce a bunch of magic methods on model instances. And my point is that we aren't talking about method composition here that you can statically analyze with a bolted-on type system. Ruby's metaprogramming runs so deep that it's a substantially bigger challenge than other dynamically-typed languages. One clue is that humans even have a hard time with it. The first shock that people have with Ruby is when you see a method or identifier and grep shows up with zero results. Aside, I can kinda tell that Ruby is entering Perl territory when there are no beginners around to chime in with their gripes.
- favorited 8y agoI only say that because it seems like low-hanging fruit. If I have a class with a random @ivar that's added inside a random method, there's nothing up-front to check against. An ActiveRecord subclass at least has a database schema to validate against.
- deleted 8y ago[deleted]
- asark 8y agoThe magic stuff's awful. Any time you have to dig into a mothballed Rails codebase from a version either older or newer than what you're used to, or with a bunch of Railsy magic gems that aren't in your usual toolkit, it's hell. I'd rather let the computer tell me what stuff is and where it's defined than memorize a bunch of magic prefixes.
- digitaltrees 8y agoI am a beginner. I don’t know enough to gripe, I bet that’s a common feeling among beginners.