qm-acts-as-generic-controller 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ begin
|
|
9
9
|
gemspec.email = "marcin@saepia.net"
|
10
10
|
gemspec.homepage = "http://q.saepia.net"
|
11
11
|
gemspec.authors = ["Marcin Lewandowski"]
|
12
|
-
gemspec.version = "0.0.
|
12
|
+
gemspec.version = "0.0.9"
|
13
13
|
gemspec.files = Rake::FileList.new [ "MIT-LICENSE", "Rakefile", "lib/*", "app/views/generic_controller/*" ]
|
14
14
|
gemspec.add_dependency "qui-common-helpers", ">= 0.0.6"
|
15
15
|
gemspec.add_dependency "rfc822"
|
@@ -74,7 +74,7 @@
|
|
74
74
|
<%- klass.generic_field_associations[attribute_name][:class_name].all.each do |element| -%>
|
75
75
|
<li>
|
76
76
|
<%- if kind == :check -%>
|
77
|
-
<%= check_box_tag "#{table_name}[#{attribute_name.to_s.singularize}_ids][]", element.id, (params[table_name]
|
77
|
+
<%= check_box_tag "#{table_name}[#{attribute_name.to_s.singularize}_ids][]", element.id, (params[table_name] && params[table_name]["#{attribute_name.to_s.singularize}_ids"] ? params[table_name]["#{attribute_name.to_s.singularize}_ids"].include?(element.id.to_s) : record.send("#{attribute_name.to_s.singularize}_ids").include?(element.id) ), :id => "#{table_name}_#{attribute_name}_#{element.id}" %>
|
78
78
|
|
79
79
|
<%- elsif kind == :radio -%>
|
80
80
|
<%= radio_button_tag "#{table_name}[#{klass.generic_field_associations[attribute_name][:foreign_key]}]", element.id, (params[table_name] ? params[table_name]["#{table_name}[#{klass.generic_field_associations[attribute_name][:foreign_key]}]"] == element.id.to_s : record.send(klass.generic_field_associations[attribute_name][:foreign_key]) == element.id), :id => "#{table_name}_#{attribute_name}_#{element.id}" %>
|
@@ -21,8 +21,25 @@
|
|
21
21
|
<%- else -%>
|
22
22
|
<%- attribute_name = field.to_sym -%>
|
23
23
|
<%- end -%>
|
24
|
+
|
24
25
|
|
25
|
-
<%-
|
26
|
+
<%- is_association = klass.generic_field_associations[attribute_name].present? -%>
|
27
|
+
<%- association = klass.generic_field_associations[attribute_name] if is_association -%>
|
28
|
+
<%- is_writable = (not is_association or (is_association and not association[:readonly])) -%>
|
29
|
+
<%- if is_writable -%>
|
30
|
+
<%- if is_association -%>
|
31
|
+
<%- if klass.generic_field_associations[attribute_name][:kind] == :has_many or klass.generic_field_associations[attribute_name][:kind] == :has_and_belongs_to_many -%>
|
32
|
+
<%- is_accessible = klass.attr_accessible.include?("#{attribute_name.to_s.singularize}_ids") -%>
|
33
|
+
<%- elsif klass.generic_field_associations[attribute_name][:kind] == :belongs_to -%>
|
34
|
+
<%- is_accessible = klass.attr_accessible.include?(association[:foreign_key].to_s) -%>
|
35
|
+
<%- end -%>
|
36
|
+
<%- else -%>
|
37
|
+
<%- is_accessible = klass.attr_accessible.include?(attribute_name.to_s) -%>
|
38
|
+
<%- end -%>
|
39
|
+
<%- end -%>
|
40
|
+
|
41
|
+
|
42
|
+
<%- if is_accessible -%>
|
26
43
|
<li>
|
27
44
|
<%= f.label attribute_name %>
|
28
45
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qm-acts-as-generic-controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 9
|
10
|
+
version: 0.0.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marcin Lewandowski
|