cainlevy / presenting

components + scaffolding == presentations — Read more

This URL has Read+Write access

presenting / params
100644 56 lines (49 sloc) 2.235 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
PARAMETER CONVENTIONS
 
Paging (WillPaginate)
  params[:page] = integer (1+)
 
Nested Models (adopt Rails' upcoming convention)
  mixed new and existing has many records
  
Sorting
  single column / direction
    params[:sort] = column.direction
    params[:sort][column] = direction
  multiple columns / directions
    params[:sort][column] = direction
    
  NOTES:
    no sql injection means that both the column and the direction should be whitelisted
    columns may not be explicit columns. they may be named_scopes, or some custom sql?
    
Searching
  single value
    params[:search] = value
  one value per column
    params[:search] = {column => value}
      name="search[foo]" value="bar"
  one value and operator per column
    params[:search] = {column => {:operator => operator, :value => value}}
      name="search[foo][operator]" value="="
      name="search[foo][value]" value="bar"
    params[:search] = {column => [operator, value]}
      name="search[foo][]" value="="
      name="search[foo][]" value="bar"
  multiple values or operators per column
    params[:search] = [{:column => column, :operator => operator, :value => value}, {}]
      name="search[3][column]" value="foo"
      name="search[3][operator]" value="="
      name="search[3][value]" value="bar"
    params[:search] = [[column, operator, value], []]
      name="search[2][]" value="foo"
      name="search[2][]" value="="
      name="search[2][]" value="bar"
    params[:search] = [{:c => column, :o => operator, :v => value}, {}]
      name="search[4][c]" value="foo"
      name="search[4][o]" value="="
      name="search[4][v]" value="bar"
  search macros (aka scopes, filters, smart searches)
    params[:scope] = value
    params[:scopes] = [value]
    
  NOTES:
    the positional params aren't self-documenting. strike.
    the full hash keys are too bulky for GET. strike.
    it's not worth combining field/operator or operator/value. that requires javascript or an expert user to combine them.
    operators should be whitelisted or interpreted, so there's no sql injection
    columns should be whitelisted or interpreted, so there's no sql injection