Created
September 4, 2008 10:35
-
-
Save masterkain/8750 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conditions = Where.new | |
conditions.or('accounts.phone like ?', '%' + params[:search] + '%') unless params[:search].blank? | |
conditions.or('groups.name like ?', '%' + params[:search] + '%') unless params[:search].blank? | |
# new rails feature, :joins permit to have conditions based on the joined table. | |
# http://ryandaigle.com/articles/2008/7/7/what-s-new-in-edge-rails-easy-join-table-conditions | |
@accounts = Account.paginate(:page => params[:page] || 1, :joins => :group, :conditions => conditions, :include => :group) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment