-
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
Popular feature #577
Popular feature #577
Conversation
@@ -14,6 +14,9 @@ class Tag < ::ActiveRecord::Base | |||
validates_uniqueness_of :name, if: :validates_name_uniqueness? | |||
validates_length_of :name, maximum: 255 | |||
|
|||
### SCOPES: | |||
scope :popular, lambda { |limit = 20| order("taggings_count desc").limit(limit) } |
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.
Use ruby 1.9.3 syntax for lambdas.
Thank you for your contribution @damzcodes . cc @bf4 |
Hi @seuros I've refractored the code now. Ran the tests on my machine and they all pass. |
@@ -20,6 +20,8 @@ def validates_name_uniqueness? | |||
end | |||
|
|||
### SCOPES: | |||
scope :most_used, -> (limit = 20) { order("taggings_count desc").limit(limit) } |
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.
->(limit = 20)
RBX don't like the space :/
The white space has been removed, hopefully it passes now. |
Rails 3.2 tests are failling :/ , i think we have to rewrite the test. |
This feature is very cool! What is missing before it can be added? |
Indeed ❤️ . |
Feature added to find popular tags Refractored using new lambda syntax, added 'least' method Removing white space Fixing test so that taggable counts are set in rails 3.2 Restoring space for readability Included information on new features 'most_used' & 'least_used' Editted to display properly
963782f
to
34a2fd5
Compare
Thank you @damzcodes 💚 |
You're most welcome. |
Popular feature
Feature for finding popular tags.