-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActiveRecord 4.1 compatibility #436
Conversation
Oh, it seems to lose AR 3 compatibility... I'll investigate. |
In ActiveRecord 3, Model.all returns an Array.
@@ -125,7 +125,7 @@ | |||
end | |||
|
|||
it "should have tag_counts_on" do | |||
TaggableModel.tag_counts_on(:tags).should be_empty | |||
TaggableModel.tag_counts_on(:tags).count(:all).should be_zero |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, so this test doesn't cover the tags.is_a?(Array)
scenario...
I tried another way to fix about |
@@ -2,7 +2,11 @@ module ActsAsTaggableOn | |||
module TagsHelper | |||
# See the README for an example using tag_cloud. | |||
def tag_cloud(tags, classes) | |||
return [] if tags.empty? | |||
if tags.is_a?(Array) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def tag_cloud(tags, classes)
return [] if no_tags?(tags)
....
end
def no_tags?(tags)
if tags.is_a?(ActiveRecord::Relation)
tags.count(:all).zero?
else
tags.blank?
end
end
See #445 (you'll probably have to rebase once it's merged) |
Oh, you know you can force push to the same remote branch and it will update the PR? |
Closed per #446 |
This PR fixes #435.