0.0
No commit activity in last 3 years
No release in over 3 years
Simple list filtering & sorting for Rails controller.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme
list_controls
=============

Simple list filtering & sorting for Rails controller. 

Plays nicely with SearchLogic.


Example
=======

Controller:

  class ProductsController < ApplicationController
    
    enable_list_controls :default_filters => { 'state' => 'new' } 
  
    def index
      @products = Product.all :conditions => { :state => @filters.state }
    end
  
  end

  # Note: 
  #
  # Sort param stored in @filters.order, example 'ascend_by_title'
  # Easy use with SearchLogic.


View:

  <div id="filters">
    <%= form_for :filters, @filters, :html => { :method => :get } do |f| %>
    
      <%= f.label :state %>
      <%= f.select :state, states_for_filter %>
    
    <% end %>
  </div>

  <table>
    <tr>
      <th><%= sort @filters, :by => :id %></th>
      <th><%= sort @filters, :by => :title, :as => t(:product_title) %></th>
      <th><%= sort @filters, :by => :state, :as => t(:state) %></th>
    </tr>
    
    <% for product in @products %>
      <tr>
        <td><%= product.id %></td>
        <td><%= product.title %></td>
        <td><%= product.state %></td>
      </tr>
    <% end %>    
  </table>


Copyright (c) 2009 Laurynas Butkus, released under the MIT license