README.md in rooble-0.4.3 vs README.md in rooble-0.4.4
- old
+ new
@@ -59,17 +59,18 @@
State.pages(20)
# => 3
```
``` ruby
-Model.paginate(page=1, max_records_per_page=nil)
+Model.paginate(page=1, max_records_per_page=nil, order_by: {id: :asc})
```
**Arguments:**
- `page` the page to pull records from
- `max_records_per_page` how many records to generate per page, this overrides the initializer option
+ - `order_by` how records will be ordered, defaults to the ID in Ascending order
`Model.paginate` will pull records for the first page. The first argument is the page number and you can also override the `max_records_per_page` config option on the second argument so that you paginate a specific page with a different amount of max records, for instance:
``` ruby
State.paginate
@@ -91,16 +92,17 @@
## Search
The search method will lookup for keyword matches within columns or records that match a given id, this means that you can essentially use it only to search in text fields or in the primary key. So for instance if you try to search against numeric columns it won't work but for that type of specific search you are better off using ActiveRecord directly. The rational behind this is that most application _open_ searches will lookup for id's, names or codes, rarely against numeric values.
``` ruby
-Model.search(fields, search_term, options={})
+Model.search(fields, search_term, options={}, order_by: {id: :asc})
```
**Arguments:**
- `fields` a string with a field name or string/symbol array with field names to make the query against
- `search_term` string with the term to search
+ - `order_by` how records will be ordered, defaults to the ID in Ascending order
- `options` a hash with a set of options. Please se below for more info.
`Model.search("name", "John")` will look for records which have **John** within the `name` attribute.
There is an extra options hash that you can pass to this method, the options are: