Add basic http authentication in Rails
Sometimes you want to add a basic security layer for your privated website or application in Rails, for those cases you can do it actually pretty easy and you just need to provide a user and password credentials in order access the Website/Web Application. For example...
If you want to retrieve all the orders that contain more than 2 shipments (Using Spree models)
[rails]
# this is using inner joins buy default from rails
Spree::Order.joins(:shipments).group("spree_shipments.order_id").having("count(spree_shipments.id) > 2")
[/rails]