4 ms·
I'm sorry but this is braindead. I'm sure there are valid use cases but optimize for the most common one: find_by_id accepts a single argument, the ID of the ob
by jtchang 14y ago
I'm sorry but this is braindead. I'm sure there are valid use cases but optimize for the most common one: find_by_id accepts a single argument, the ID of the object you want to find.
That is why Python has kwargs. Those two stars stand out like a sore thumb and when you are passing positional arguments in the form of a hash it is pretty apparent.
- steveklabnik 14y agoRuby does not yet have kwargs, but the upcoming Ruby 2.0 has a form of them.
- deleted 14y ago[deleted]
- mattmcknight 14y agothat would be called .find(id) - accepts a single argument of an id. This is the canonical way to retrieve by id. find_by_id, find_by_name, etc. aren't really methods, they trigger calls to method_missing which interprets the code to generate SQL. It's a "neat" feature, but one which I've only used once or twice in 6 years of Rails development.