Add an ‘about’ method to your Rails app

11 Apr

Bob Roberts:

Man, after dealing with legacy code so many times, this is a great idea. Many times developers forget (or don’t care?) about the next developer that will work on the code someday. This would be good to throw into a rake task to create the full list of descriptions. Thanks for this!!

Originally posted on livingjim:

I end up using Ruby on Rails apps as tools within larger projects, not as an end to a web application need.  As such, my involvement with my Rails app may go months between those intensive times where my head is in the Rails app, and I forget many of the nuances and whys of the architecture.  So I recently built up a little extra goodness in my current project to help me when I return to it next time.

In short, I have added to each model a “description” method that just (now anyway) prints out my thinking about what the model is there for and how it is to be used, what caveats exist in the model, and so on.  So if my app has a Product model, I can work in the Rails console with it and issue a Product.description call to print out all that stored…

View original 166 more words


Posted by on April 11, 2014 in Ruby on Rails


5 responses to “Add an ‘about’ method to your Rails app

  1. m3talsmith (@m3talsmith)

    April 12, 2014 at 9:13 am

    This is a bad idea! Every time you spin the app up it’s going to churn through the code and try to put out descriptions that then get outputted in your logs! Talk about overkill!

    I agree that people need to know about the app, that’s what README and ./doc/ are for.

    A better version of this would be to leave sdoc [ ] comments in your code documenting what it does, then when you “`rake test“` it will automatically build your documentation for you. Anyone that wants to see the documentation can open ./doc/index.html and “viola!” instant searchable documentation.

    If you want a tl;dr simply put the summary in the README: with a bonus here, github will render it nicely so that any developer looking at the project get’s a pretty summary to start off with.

    So yes, make an about section, but put it in documentation and summarize in the README. Doing the process mentioned in this blog post will clutter your logs and slow your app down.

    • Bob Roberts

      April 13, 2014 at 2:05 pm

      Well it wouldn’t need to go in an initializer. I was thinking of more along the lines of running rake task to compile the documentation.

      And using a well written READ is great. I think what I took away from him post is that he writes noted in his about in his models and controller while he is in them working on them. These could also then later be copied into the README.

    • livingjim

      April 28, 2014 at 10:43 pm

      So I just cleared out my log files and spun the app up, first through console and then the server. No output to log files and no delays. My inspiration for this idea came, by the way, from all the unix tools that accept arguments, but if you provide none they offer a brief amount of help on how to use them.

  2. livingjim

    April 28, 2014 at 3:20 pm

    Which idea is bad? A rake task or my class description methods? Honestly I don’t see how either would impact start up times. I can verify that my log files aren’t full of description messages. And launch times haven’t grown.

    • Bob Roberts

      April 28, 2014 at 7:52 pm

      I like the idea myself. Makes sense to me ;)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: