make 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/make/form.rb +8 -6
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04792a26bac9776862679ea78c6451de9b955a41
|
4
|
+
data.tar.gz: 747cfe1b615afe13a3e5af67bf970938b51724ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ca25d91b609c87f5bd9dd42e115fda83a45553ef5313eb86bfe4019fa217b535618c3a93c158dad8e48745fc2ab652533f02a11b41f67e513f7f650c69005b9
|
7
|
+
data.tar.gz: da223904d126f9b338d61cdc3e77f5490f37aedd0632bc636286cda260ae1ffbf085688618e290b7eb202773bd2019d1ce50a2a0862aae2d345ce4e8d9f9e620
|
data/lib/make/form.rb
CHANGED
@@ -63,10 +63,12 @@ class Form
|
|
63
63
|
return self
|
64
64
|
end
|
65
65
|
# Similar to default, but instead of a hidden specific value you pass in an array and create a select/option field.
|
66
|
-
def select column, array
|
66
|
+
def select column, array
|
67
67
|
columnName = column.titleize
|
68
|
-
input = "\n\t<label>" + columnName + "
|
69
|
-
|
68
|
+
input = "\n\t<label>" + columnName + "</label>\n\t<select name=\"" + @modelName + "[" + column + "]\">"
|
69
|
+
array.each |item| do
|
70
|
+
input += "\n\t\t<option value=\"" + item.to_s + "\">" + item.to_s + "</option>"
|
71
|
+
end
|
70
72
|
@potential_keys_to_ignore.push(column)
|
71
73
|
input += "\n\t</select>"
|
72
74
|
@formMiddle.push(input)
|
@@ -77,7 +79,7 @@ class Form
|
|
77
79
|
# titleize column
|
78
80
|
columnName = column.titleize
|
79
81
|
# Create for input
|
80
|
-
input = "\n\t<label>" + columnName + "
|
82
|
+
input = "\n\t<label>" + columnName + "</label>\n\t<select name=\"" + @modelName + "[" + column + "]\">"
|
81
83
|
# Remove _id and take the assocModel unless assocModel exists
|
82
84
|
if assoc_model
|
83
85
|
assoc_model = assoc_model.capitalize.constantize
|
@@ -90,7 +92,7 @@ class Form
|
|
90
92
|
counter = 1
|
91
93
|
while counter <= total do
|
92
94
|
val = assoc_model.find(counter).attributes[assoc_column]
|
93
|
-
input += "\n\t\t
|
95
|
+
input += "\n\t\t<option value=\"" + counter.to_s + "\">" + val.to_s + "</option>"
|
94
96
|
counter+= 1
|
95
97
|
end
|
96
98
|
input += "\n\t</select>"
|
@@ -129,7 +131,7 @@ class Form
|
|
129
131
|
input = "\n\t<label>"+column.titleize+"</label>\n\t<input type=\"date\" name=\"" + @modelName + "[" + column + "]\">"
|
130
132
|
@formMiddle.push(input)
|
131
133
|
else
|
132
|
-
input = "\n\t<label>" + column.titleize + "
|
134
|
+
input = "\n\t<label>" + column.titleize + "</label>\n\t<input type=\"text\" name=\"" + @modelName + "[" + column + "]\">"
|
133
135
|
@formMiddle.push(input)
|
134
136
|
end
|
135
137
|
end
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sara Wong
|
@@ -12,10 +12,10 @@ cert_chain: []
|
|
12
12
|
date: 2014-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A gem that shortcuts typing out forms and tables for SQL users. Assuming
|
15
|
-
your model is named ModelName, just type Make.form.model(ModelName).now! in your
|
16
|
-
controller and it will return an html-safe
|
17
|
-
a new record. In addition, you can type Make.table.model("ModelName").now!
|
18
|
-
generate a table.
|
15
|
+
your model is named ModelName, just type Make.form.model("ModelName").now! in your
|
16
|
+
controller and it will return an html-safe form based on your column names for creating
|
17
|
+
a new record in your view. In addition, you can type Make.table.model("ModelName").now!
|
18
|
+
to automatically generate a table.
|
19
19
|
email:
|
20
20
|
- swong2@wellesley.edu
|
21
21
|
- utemoc@gmail.com
|