rails_rateable 0.0.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c0770a073f90fffb1bfd2cc9b8d786585ed0848
4
- data.tar.gz: 17ab4e67a4f49694a7afaec5c6a5595d1afe3d65
3
+ metadata.gz: 025c051445f757aaa2aa31f8dc8aee7dcfd00122
4
+ data.tar.gz: c61f328b9fbe752bbdb76c7c02546b3f3d912729
5
5
  SHA512:
6
- metadata.gz: 613e77a3f6ae71d6a662dfadc6e0f9eb5d6f05c1020efc3725b4ea788ca00e00b84a79f8c755baee211e898ed8e59698af248a3452ce668bcc126933b537d8b8
7
- data.tar.gz: 251252e3e85b0574d529540874f1596214eb89d331b2d0d86e33508752f5f665ece10e52a28a0ecb2ec93d64820b11e5f34f422fbce75a2b8ddee2284e0bedf7
6
+ metadata.gz: edddebccb41fb830a22b89c0b59ae2be4c35bf66c175cbf44393570270a5df6094c0e51fa4bf29560900e19edca868e9d6f87e09b808871973a4d1dd8fb83065
7
+ data.tar.gz: 02f81100bb78c24e8dae26be9c55a8b2e7a47acfd10943cb3da6c43ee63c71d79ac13288a8e44bd313ffd856a1dd0aa926375ca93037a1ec5dd3c3c295a5459b
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  = Rateble
2
2
 
3
- rateable is a rails gem providing a rating interface for ActiveRecord models.
3
+ rails_rateable is a rails gem providing a rating interface for ActiveRecord models.
4
4
  It is compitable only with Rails 3 and above. It is released under the MIT license.
5
5
 
6
6
 
@@ -40,7 +40,19 @@ Add 'include RailsRateable' to the modal you want to make rateable, then restart
40
40
  include RailsRateable
41
41
  end
42
42
 
43
- Now your model is extended by the plugin, you can rate it (1-#) or calculate the average rating.
43
+ Now your model is extended by the Gem, you can rate it (1-#) or calculate the average rating.
44
+
45
+
46
+ By default max_rating is 5 i,e user can give rating from 1 to 5 . You can override it by passing max_rating parameter
47
+ to rails_rateable
48
+
49
+ In Below example, Comment model is made rateable and max_rating set to 10, so for comment user can provide rating between 1 to 10
50
+
51
+ class Comment < ActiveRecord::Base
52
+ include RailsRateable
53
+ rails_rateable :max_rating => 10
54
+ end
55
+
44
56
 
45
57
  @movie.rate_it(4, current_user)
46
58
 
@@ -53,11 +65,11 @@ Now your model is extended by the plugin, you can rate it (1-#) or calculate the
53
65
 
54
66
  Movie.find_top_rated #=> top rated records
55
67
 
56
- Optional you can specify the highest score using the :max_rating paramter as follows. The default for :max_rating is 5.
68
+ By default 20 top rated result will be returned. Youu can override it by passing numer of record you want.
69
+
70
+ Movie.find_top_rated(40) # will return 40 records
71
+
57
72
 
58
- class Comment < ActiveRecord::Base
59
- acts_as_rateable :max_rating => 10
60
- end
61
73
 
62
74
 
63
75
  CREDIT:
@@ -7,18 +7,16 @@ module RailsRateable
7
7
 
8
8
  module ClassMethods
9
9
  #put class method here to be trigger as say User.method_name
10
- def acts_as_rateable(options = {})
10
+ def rails_rateable(options = {})
11
11
  unless respond_to?(:max_rating)
12
12
  class_attribute :max_rating
13
13
  self.max_rating = options[:max_rating] || 5
14
14
  end
15
15
  end
16
16
 
17
- def find_top_rated(params = {})
18
- find_params = params.merge(:include => :rating)
19
- find_params[:order] = ['ratings.average_rating DESC', find_params.delete(:order)].compact.join(", ")
20
- find_params[:limit] = 20 unless find_params.key?(:limit)
21
- find(:all, find_params)
17
+ def find_top_rated(limit = nil)
18
+ limit = 20 unless limit
19
+ includes(:rating).order('ratings.average_rating DESC').limit(limit)
22
20
  end
23
21
 
24
22
  end
@@ -1,3 +1,3 @@
1
1
  module RailsRateable
2
- VERSION = "0.0.2"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_rateable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-02 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler