Skip to content
This repository
Browse code

Updated readme

  • Loading branch information...
commit dcf6ebf83b5ab96d6e650f1825526457a6bfe712 1 parent 760ba27
Ben Johnson authored September 02, 2008

Showing 2 changed files with 20 additions and 20 deletions. Show diff stats Hide diff stats

  1. 2  CHANGELOG
  2. 38  README.mdown
2  CHANGELOG
... ...
@@ -1,3 +1,3 @@
1  
-v0.9.1 Added aliases for datetime, date, time, and timestamp attrs. You could call created_at_after, mow you can also call created_after.
  1
+v0.9.1. Added aliases for datetime, date, time, and timestamp attrs. You could call created_at_after, mow you can also call created_after.
2 2
 
3 3
 v0.9.0. First release
38  README.mdown
Source Rendered
@@ -44,7 +44,7 @@ Now go into your console and try out any of these example with your own models.
44 44
 ## Detailed Example w/ object based searching
45 45
 
46 46
     # Instantiate
47  
-    search = User.new_search(
  47
+    @search = User.new_search(
48 48
         :conditions => {
49 49
             :first_name_contains => "Ben", 
50 50
             :age_gt => 18,
@@ -57,21 +57,31 @@ Now go into your console and try out any of these example with your own models.
57 57
     )
58 58
     
59 59
     # Set conditions on relationships
60  
-    search.conditions.email_ends_with = "binarylogic.com"
61  
-    search.conditions.oders.line_items.created_after = Time.now
  60
+    @search.conditions.email_ends_with = "binarylogic.com"
  61
+    @search.conditions.oders.line_items.created_after = Time.now
62 62
     
63 63
     # Set options
64  
-    search.per_page = 50 # overrides the 20 set above
  64
+    @search.per_page = 50 # overrides the 20 set above
65 65
     
66 66
     # Set ANY of the ActiveRecord options
67  
-    search.group = "last_name"
68  
-    search.readonly = true
  67
+    @search.group = "last_name"
  68
+    @search.readonly = true
69 69
     # ... see ActiveRecord documentation
70 70
     
71 71
     # Return results just like ActiveRecord
72  
-    search.all
73  
-    search.search # alias for all
74  
-    search.first
  72
+    @search.all
  73
+    @search.search # alias for all
  74
+    @search.first
  75
+
  76
+**As you can see, you could pass the search object right into form\_for:**
  77
+
  78
+    <%= form_for :search, @search.conditions, :url => users_path do |f| %>
  79
+        <%= f.text_field :first_name_contains %>
  80
+        <%= f.calendar_date_select :create_after %> # nice rails plugin for replacing date_select
  81
+        <% f.fields_for :orders, f.object.orders do |orders_f| %>
  82
+            <%= f.select :total_gt, (1..100) %>
  83
+        <% end %>
  84
+    <% end %>
75 85
 
76 86
 ## Calculations
77 87
 
@@ -223,16 +233,6 @@ Some of these conditions come with aliases, so you have your choice how to call
223 233
 
224 234
 You will notice above there is "contains" and "keywords". The difference is that "keywords" is an enhanced search. It acts like a real keyword search. It finds those keywords, in any order, and blacklists meaningless words such as "and", "the", etc. "contains" finds the EXACT string in the column you are searching, spaces and all.
225 235
 
226  
-## Creating your search form
227  
-
228  
-After all of that, here's why I love this plugin:
229  
-
230  
-    <% form_for :search, User.new_conditions, :url => users_path do |f| %>
231  
-        <%= f.text_field :first_name_contains %>
232  
-        <%= f.calendar_date_select :created_after %>
233  
-        <%= f.select :age_gt, (1..100) %>
234  
-    <% end %>
235  
-
236 236
 ## Credits
237 237
 
238 238
 Author: [Ben Johnson](http://github.com/binarylogic) of [Binary Logic](http://www.binarylogic.com)

0 notes on commit dcf6ebf

Please sign in to comment.
Something went wrong with that request. Please try again.