Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated Readme and License

  • Loading branch information...
commit af777bb61d5714e3296709ddd48c81021e94d945 1 parent 2b3e1e4
@benedikt authored
Showing with 29 additions and 16 deletions.
  1. +1 −1  LICENSE
  2. +28 −15 README.rdoc
View
2  LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2009 Benedikt Deicke
+Copyright (c) 2009, 2010 Benedikt Deicke
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
43 README.rdoc
@@ -1,6 +1,6 @@
= filter_fu
-This Ruby on Rails plugin adds a filtered_by method to your models. It accepts a hash of filters that are applied using named_scopes. In addition the plugin adds some view helpers to easily build filter forms.
+This Ruby on Rails plugin adds a <tt>.filtered_by</tt> method to your models. It accepts a hash of filters that are applied using scopes. In addition the plugin adds some view helpers to easily build filter forms.
== Install
@@ -8,15 +8,17 @@ You can install filter_fu as a gem or as a rails plugin.
=== Install as gem
-Add this line to your <tt>config/environment.rb</tt> and run <tt>rake gems:install</tt>
+To install the filter_fu gem, simply add it to your Gemfile:
- config.gem 'filter_fu', :source => 'http://www.gemcutter.org'
-
-=== Install as plugin
+ gem 'filter_fu'
+
+In order to get the latest development version of filter_fu:
+
+ gem 'filter_fu', :git => 'git://github.com/benedikt/filter_fu.git'
-Run this command in your currrent project's +RAILS_ROOT+
+and run
- ./script/plugin install git://github.com/benedikt/filter_fu.git
+ bundle install
== Usage
@@ -24,21 +26,21 @@ Run this command in your currrent project's +RAILS_ROOT+
To enable filter_fu on a model, simply add one line to its definition:
- class Project
+ class Project < ActiveRecord::Base
filter_fu
end
Let's say you don't want your Projects list filtered by its +hidden+ column. You can easly
tell filter_fu to ignore certian named scopes or columns:
- class Project
+ class Project < ActiveRecord::Base
filter_fu :except => [:hidden]
end
Of course this also works the other way round using the <tt>:only</tt> option to only allow filtering
for the given named scopes or columns:
- class Project
+ class Project < ActiveRecord::Base
filter_fu :only => [:starts_on, :ends_on]
end
@@ -46,30 +48,41 @@ Once you enabled filter_fu on your model it provides a filtered_by method.
Project.filtered_by(params[:filter])
Project.filtered_by(params[:filter]).some.named_scopes
- Project.some.other.named_scopes.filtered_by(params[:filter])
+ Project.some.other.scopes.filtered_by(params[:filter])
=== Helper
filter_fu comes with helpers to simplify the generation of filter forms:
- <% filter_form do |f| %>
+ <%= filter_form do |f| %>
# f is a ActionView::Helpers::FormBuilder
<% end %>
You can also specify a name for the filter (Default is <tt>:filter</tt>). This way you're able to have multiple filters on the same page.
- <% filter_form_for(:product_filter) do |f| %>
+ <%= filter_form_for(:product_filter) do |f| %>
# f is a ActionView::Helpers::FormBuilder
<% end %>
filter_fu will automatically include all other parameters for the current page (ie. pagination parameters) within the form.
If you wish to explicitly exclude some you can do this by passing an array as :ignore_parameters option.
- <% filter_form_for(:product_filter, :ignore_parameters => [:page]) do |f| %>
+ <%= filter_form_for(:product_filter, :ignore_parameters => [:page]) do |f| %>
# f is a ActionView::Helpers::FormBuilder
<% end %>
+
+
+== Known issues
+
+See http://github.com/benedikt/filter_fu/issues
+
+== Repository
+
+See http://github.com/benedikt/filter_fu and feel free to fork it!
+
+
== Copyright
-Copyright (c) 2009 Benedikt Deicke. See LICENSE for details.
+Copyright (c) 2009, 2010 Benedikt Deicke. See LICENSE for details.
Please sign in to comment.
Something went wrong with that request. Please try again.