Campaign_2010
Highrise
Qlikview
Leanisolutions
Think web solutions. Think Leanis.

At Leanis, we dare to be different. Whether it's a web application or a corporate website, we believe that every ounce of our energy and focus should be put into understanding the business aspect as well as the creativity and functionality of the entire solution. We understand that business has always been the driver, steering IT as the enabler. Built with this in mind, our methodology allows us to understand the problems faced in processes and operations of your business to tailor develop web based applications that are simplistic yet powerful.

Looking for a quality web design company?

Look no further. Our team of web designer, web developers and business consultants are ready to hear from you.

Can’t find anything suitable off the shelf?

Why not look for a custom made web application that fits perfectly like a tailored made suit? With our development methodology, you’ll be glad that you’ve made the right decision.

What if you could have immediate access to all your business data, with dashboards that shows you all the KPIs you need to know and have unlimited “slice & dice” drill down into your data.

Latest Article
More Articles >
  • January 2010

    Chaining Named Scopes

    There aren’t many examples of how to combine named_scopes programmatically on the ol’ Blogosphere these days. All I could find were a few scant references to using anonymous scopes like this. It took me quite a while to figure this out which is surprising since this use case seems like such a common thing to do.

    If you want to stack conditions on a search form with will_paginate on top of that, this seems to be the spice.

    class Shape < ActiveRecord::Base
    named_scope :created_after, lambda { |m| {:conditions => ["created_at > ?", m]} }
    named_scope :with_color, lambda { |color| {:conditions => {:color => color}} }
    end

    class ShapesController < ApplicationController
    def index
    scope = Shape.scoped({})
    scope = scope.created_after(params[:months_ago].to_i.months.ago) if params[:months_ago]
    scope = scope.with_color(params[:color]) if params[:color]
    @shapes = scope.paginate(paginate_options({:order => 'id DESC', :page => 1}))
    end
    end

    I started to use eval to do this, but Ken Turner set me straight today. I view eval as more of a last resort when all else fails. In this case, it’s possible to tap these filters in using a rubber mallet. No sense in busting out the sledgehammer for this one.

     

    Source: involution.com/2008/11/10/chaining-named-scopes/
    Author: Tony Perrie

We are proud to be a MSC status company. Click here to understand more.

Bookmark and Share