Simple Quarter Select – Rails plugin for Q1,Q2,Q3,Q4 selector

Have you ever wanted a select component for Quaters of the Fiscal Year (Q1,Q2,Q3,Q4)? The Simple Quarter Select Ruby on Rails plugin does it for you. It’s highly configurable and maps to the month of any datetime attribute in your model.
Simple Quarter Select screen shot
Why map the quarter to a datetime attribute?
I think the answer is obvious but for the sake of being comprehensive, I’ll list 3 questions to guide your decision:
1) How else would you store the information in your database?
2) What if some of your objects are quarterly but others are actual dates? How about semiannual?
3) How would your sort-by-date query look?

If you answer these 3 questions, you will likely see the logic in my decision.

Get it or view the source here

It’s really easy to use. Just toss this code into your view:

<%= date_select(:some_model, :some_date_attribute, {:discard_day => true, :order => [:month,:year], 
:simple_quarter_select => true}) %>

Simple Quarter Select has a misleading name. It should really be called “Named Month Intervals” because that represents its true flexibility. To illustrate this, let’s look at an example. Let’s say you want your users to be able to choose from two halves of a year:

<%= date_select(:some_model, :some_date_attribute, {:discard_day => true, :order => [:month,:year], 
:simple_quarter_select => true, :month_interval => 6, :interval_names => ["H1","H2"]}) %>

Simple Quarter Select sample configuration screenshot
“H1″ would store as 01/01/YYYY and “H2″ would store as 07/01/YYYY.

Or maybe you just want to display the full word “Quarter” in each option:

<%= date_select(:some_model, :some_date_attribute, {:discard_day => true, :order => [:month,:year], 
:simple_quarter_select => true, :interval_names => ["Quarter 1","Quarter 2","Quarter 3","Quarter 4"]}) %>

You get the idea :)

Let me know if you find this plugin useful or find any bugs. Enjoy!

No TweetBacks yet. (Be the first to Tweet this post)
Share and Enjoy:
  • Digg
  • Facebook
  • Google
  • MySpace
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis

If you enjoyed this post, make sure you subscribe to my RSS feed!

This entry was posted in Software and tagged , , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.