5 ms·
If there's anything destructive about that interactive session, it's likely to be the 'authorize_ghosting!' call. Somehow, I find it hard to believe sticking it
by tedunangst 12y ago
If there's anything destructive about that interactive session, it's likely to be the 'authorize_ghosting!' call. Somehow, I find it hard to believe sticking it in a one line script would make it less destructive, but let's see.
User.find_by_email(ARGV[0]).authorize_ghosting!(ARGV[1])
Oh, yes, so much better. patio11 should totally switch to using this. And then pay me my $1000 consulting fee.
- hamburglar 12y agoI'm going to go out on a limb and suggest that it shouldn't just be turned into a one-liner that shoves ARGV elements directly at the database, but should actually do some validation of input. Even your one-liner is safer than raw irb since you can't make a typo and call the wrong method, but if you add validation, then yes, I think it's much, much less destructive.
- deleted 12y ago[deleted]
- tlrobinson 12y agoWhat sort of validation? Either you provide a valid email address that exists and it works, or not.
- hamburglar 12y agoI suppose when the args are both allowed to be arbitrary strings, the validation is already done, and the escaping is done by AR, so you can safely pass them unmolested. It just triggers my safety reflex to send ARGV elements on to the next layer without doing something to them.