20 ms·
I agree with the gem list. I think it should have been #1. Using OpenStruct as a replacement for a user doesn't remove the conditionnal, it just removes it fro
by pothibo 12y ago
I agree with the gem list. I think it should have been #1.
Using OpenStruct as a replacement for a user doesn't remove the conditionnal, it just removes it from that use case. You still need to know if the user is logged in or not.
- BrianVanLoo 12y agoGlad to see some support on the gem list. That was one of the items I really hadn't seen discussed anywhere else and was wondering if it only bothered me. I did some dev ops for a project that turned out to be what would have sounded like a fairly simple, small Rails app on a rather low-traffic site. I kept having to increase the server instance size as the team cargo-culted more and more gems into the Gemfile and the multiple Rails executables run under Unicorn continued to grow in size and eventually run out of memory on the server. I agree that my example using OpenStruct only moves the conditional but in this case it moves it out of a place where I find conditional logic much harder to reason about. Also, if there were more attributes than just name that come out of that object you could potentially be eliminating many more conditionals with just the one in current_user which also seems like a win.