bowtie 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bowtie.gemspec +1 -1
- data/lib/bowtie/adapters/datamapper.rb +12 -0
- data/lib/bowtie/adapters/mongomapper.rb +4 -0
- data/lib/bowtie/helpers.rb +1 -1
- metadata +5 -5
data/bowtie.gemspec
CHANGED
@@ -57,6 +57,18 @@ module Bowtie
|
|
57
57
|
assoc.class == DataMapper::Associations::OneToOne::Relationship
|
58
58
|
end
|
59
59
|
|
60
|
+
# i have to say this: datamapper sucks. when calling record.association.count
|
61
|
+
# it actually fetches all the records, builds an array and then calls count on
|
62
|
+
# that array.
|
63
|
+
def self.get_count(record, association)
|
64
|
+
association_key = "#{record.class.name.downcase}_#{record.class.primary_key}"
|
65
|
+
begin
|
66
|
+
repository.adapter.select("select count(*) from #{association} where #{association_key} = ?", record.primary_key)
|
67
|
+
rescue DataObjects::SQLError => e # probably has_many :through => association
|
68
|
+
''
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
60
72
|
module Helpers
|
61
73
|
|
62
74
|
def total_entries(resources)
|
data/lib/bowtie/helpers.rb
CHANGED
@@ -79,7 +79,7 @@ module Bowtie
|
|
79
79
|
if Bowtie.has_one_association?(assoc) || Bowtie.belongs_to_association?(assoc)
|
80
80
|
html += (r.send(rel_name).nil? ? 'nil' : "View #{rel_name.to_s}")
|
81
81
|
else
|
82
|
-
html +=
|
82
|
+
html += Bowtie.get_count(r, rel_name).to_s
|
83
83
|
end
|
84
84
|
html += "</a></td>"
|
85
85
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bowtie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 5
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 5
|
10
|
+
version: 0.4.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Tom\xC3\xA1s Pollak"
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
requirements: []
|
107
107
|
|
108
108
|
rubyforge_project: bowtie
|
109
|
-
rubygems_version: 1.
|
109
|
+
rubygems_version: 1.5.2
|
110
110
|
signing_key:
|
111
111
|
specification_version: 3
|
112
112
|
summary: Bowtie Admin Scaffold
|