make 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/make/form.rb +28 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b2234e2d4176ca5874af7a9cdd95a9b63c32e10
4
- data.tar.gz: 551c44234a30e2ca00a4838789449c734fb39645
3
+ metadata.gz: 13d4a9d819e59a3736ad889e48f6b64093215cd5
4
+ data.tar.gz: 859571be189a93332bafd94f477eb6efe811bc2d
5
5
  SHA512:
6
- metadata.gz: 5b874eb888f4ce1d9b98951ccec327d01aa2c6fc654a6b55c9402d8ad76524ab12cf9220c32a0536731264e405e9478379f77705007a9fa24cc25cf3a250ea58
7
- data.tar.gz: b55665fd0b928d348c6645bdf311c92c2054b19ff3d7e2461ec5a54268871611a48284808889551718058119a0046f9d4d6e67b4c7484652bf432c36cee73323
6
+ metadata.gz: e5bd0d1e3ef3389855bff0dbb53113c48033d26df40bda17674cb2c4009b28686363624fe2ea4ddbe0e627eab1565bb370b18c321e8a2f961a6ba54a86687bff
7
+ data.tar.gz: 6d5db6e0b775102a84935cd1743748d0f781e0595272e5b63adaa81cb38ef5aad2eb7031ef99bc1888a4345eb3c8da14f5db51cfcc4fa1a44c5191f2861830c3
@@ -32,6 +32,13 @@ class Form
32
32
  @formAction = url
33
33
  return self
34
34
  end
35
+ # hide array of specific fields that should not be submitted through
36
+ def hide columns
37
+ columns.each do |col|
38
+ @potential_keys_to_ignore.push(col.to_s)
39
+ end
40
+ return self
41
+ end
35
42
  # Change form class
36
43
  def class myClass
37
44
  @formClass = myClass
@@ -74,6 +81,27 @@ class Form
74
81
  @formMiddle.push(input)
75
82
  return self
76
83
  end
84
+ # Similar to select, but association assumed and specific associated column name can be selected
85
+ def assoc column, assocColumn, array='all'
86
+ columnName = column.titleize
87
+ input = "\n\t<label>" + columnName + "\n\t</label>\n\t<select name=\"" + @modelName + "[" + column + "]\">"
88
+ assocModel = column[0...-3].capitalize.constantize
89
+ array = assocModel.distinct.count('id')
90
+ assocModel.attributes.each_with_index do |attribute, index|
91
+ if attribute.key == assocColumn
92
+ assocIndex = index
93
+ end
94
+ end
95
+ while array > 0
96
+ val = assocModel.find(id).attributes.values[assocIndex]
97
+ input += "\n\t\t\t<option value=\"" + id.to_s + "\">" + val.to_s + "</option>"
98
+ array --
99
+ end
100
+ input += "\n\t</select>"
101
+ @potential_keys_to_ignore.push(column)
102
+ @formMiddle.push(input)
103
+ return self
104
+ end
77
105
  # Build starting code from class variables called upon by now!
78
106
  def starter
79
107
  if @formMethodHidden
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: make
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sara Wong