I'm a Floridian web engineer who planted his roots in Paris. Some of my favorite past-times are analyzing and optimizing development processes, building solid APIs, mentoring junior devs, and long walks on the beach.
So, the other day I ran into a problem. I have a simple
admin? function that I use to tell whether I can show admin links and it also restricts access to admin sections of the site. So I have a function which I need to use in both views and controllers. The problem is that I don't have a really good place to define this. Since if I put it in an
application_controller, I won't be able to use it in the views and if I put it in the application_helper I won't be able to use it in the controllers.
The only thing I could think of was putting it in both. Which is dumb b/c when I have to come back and change it later, I'll forget to change it in both places.
I ended up making a module called Auth and requiring that in both my
application_controller and my
application_helper. The examples I saw used it as follows:
However I went in favor of:
Since that makes it a little more clear that this isn't a model.