You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
I've got two tables (Posts and Tags), which are related many-to-many (using DMs auto-generated table). Not sure if I need to specify this, but the Tag table only has the name column (no id).
I wanted to make a class method to use in the json output that will return the amount of posts under a tag (so I can output the page count). I put the following method in the Post class:
def self.total_pages
(self.count / 48).ceil
end
which works when calling Post.total_pages, but not when calling Tag.get('randomtagname'). The following error appears when trying the latter:
DataObjects::SyntaxError: ERROR: column posts.tag_name does not exist
LINE 1: ...tags" ON "posts"."id" = "post_tags"."post_id" AND "posts"."t...
^
(code: 50360452, sql state: 42703, query: SELECT COUNT(*) FROM "posts" INNER JOIN "post_tags" ON "posts"."id" = "post_tags"."post_id" AND "posts"."tag_name" = 'purplegalaxies' INNER JOIN "tags" ON "post_tags"."tag_name" = "tags"."name" WHERE "post_tags"."tag_name" = 'purplegalaxies', uri: postgres:tom@localhost/hash_tagging?scheme=postgres&user=tom&password=&host=localhost&port=&path=/hash_tagging&query=&fragment=&adapter=postgres)
from /Users/tom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/dm-aggregates-1.2.0/lib/dm-aggregates/adapters/dm-do-adapter.rb:20:in `execute_reader'
from /Users/tom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/dm-aggregates-1.2.0/lib/dm-aggregates/adapters/dm-do-adapter.rb:20:in `block in aggregate'
from /Users/tom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:276:in `with_connection'
from /Users/tom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/dm-aggregates-1.2.0/lib/dm-aggregates/adapters/dm-do-adapter.rb:14:in `aggregate'
from /Users/tom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/dm-aggregates-1.2.0/lib/dm-aggregates/repository.rb:8:in `aggregate'
from /Users/tom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/dm-aggregates-1.2.0/lib/dm-aggregates/functions.rb:185:in `aggregate'
from /Users/tom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/dm-aggregates-1.2.0/lib/dm-aggregates/functions.rb:40:in `count'
from /Users/tom/Dropbox/Web/blackmilk-repositories/hash-tagging/models.rb:34:in `total_pages'
from /Users/tom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/collection.rb:1466:in `block in delegate_to_model'
from /Users/tom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/model/scope.rb:53:in `block in with_scope'
from /Users/tom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/model/scope.rb:73:in `with_exclusive_scope'
from /Users/tom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/model/scope.rb:53:in `with_scope'
from /Users/tom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/collection.rb:1465:in `delegate_to_model'
from /Users/tom/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/collection.rb:1444:in `method_missing'
from (irb):4
from /Users/tom/.rbenv/versions/1.9.3-p194/bin/irb:12:in `<main>'
I apologize in advance if this isn't a bug, and it's actually something I've done wrong.
The text was updated successfully, but these errors were encountered:
Hey There,
I've got two tables (Posts and Tags), which are related many-to-many (using DMs auto-generated table). Not sure if I need to specify this, but the Tag table only has the name column (no id).
I wanted to make a class method to use in the json output that will return the amount of posts under a tag (so I can output the page count). I put the following method in the Post class:
which works when calling
Post.total_pages
, but not when callingTag.get('randomtagname')
. The following error appears when trying the latter:I apologize in advance if this isn't a bug, and it's actually something I've done wrong.
The text was updated successfully, but these errors were encountered: