I needed to do the same thing for a chart where you could select the period of the data that should be displayed.
Therefore I introduced the CSS class 'btn-group-radio' and used the following unobtrusive javascript one-liner:
// application.js
$(document).ready(function() {
$('.btn-group-radio .btn').click(function() {
$(this).addClass('active').siblings('.btn').removeClass('active');
});
});
And here is the HTML:
<!-- some arbitrary view -->
<div class="btn-group btn-group-radio">
<%= link_to '1W', charts_path('1W'), class: 'btn btn-default active', remote: true %>
<%= link_to '1M', charts_path('1M'), class: 'btn btn-default', remote: true %>
<%= link_to '3M', charts_path('3M'), class: 'btn btn-default', remote: true %>
<%= link_to '6M', charts_path('6M'), class: 'btn btn-default', remote: true %>
<%= link_to '1Y', charts_path('1Y'), class: 'btn btn-default', remote: true %>
<%= link_to 'All', charts_path('all'), class: 'btn btn-default', remote: true %>
</div>