ajaxful_rating 2.2.5 → 2.2.6

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ == 2.2.6 May 27, 2010
2
+ * Fix wrapper_dom_id with false values for keys
3
+
1
4
  == 2.2.5 May 21, 2010
2
5
  * Fix wrapper_dom_id with empty values
3
6
 
data/README.textile CHANGED
@@ -64,8 +64,7 @@ class Car < ActiveRecord::Base
64
64
  end
65
65
  </pre>
66
66
 
67
- Then you need to add a call @ajaxful_rater@ in the user model. This includes a simple line so
68
- you can add it _by your own_ as well (@has_many :rates@).
67
+ Then you need to add a call @ajaxful_rater@ in the user model to make your @User@ model able to rate objects.
69
68
 
70
69
  <pre>
71
70
  class User < ActiveRecord::Base
@@ -122,9 +121,13 @@ correct action in your controller:
122
121
  <%= ratings_for @article, :remote_options => {:url => your_rate_path(@article)} %>
123
122
  </pre>
124
123
 
124
+ h3. Important!
125
+
125
126
  *To display the stars properly you need to add a call in the head of your layout, which will generate the
126
127
  required CSS style for the list. Also don't forget to include the javascripts.*
127
128
 
129
+ It's also important to note that this call MUST be within your head tags in your layout, as for now it seems to doesn't work with the @content_for@ tag.
130
+
128
131
  <pre>
129
132
  #within the head tags of your layout...
130
133
  <%= javascript_include_tag :defaults %>
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('ajaxful_rating', '2.2.5') do |p|
5
+ Echoe.new('ajaxful_rating', '2.2.6') do |p|
6
6
  p.description = "Provides a simple way to add rating functionality to your application."
7
7
  p.url = "http://github.com/edgarjs/ajaxful-rating"
8
8
  p.author = "Edgar J. Suarez"
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ajaxful_rating}
5
- s.version = "2.2.5"
5
+ s.version = "2.2.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Edgar J. Suarez"]
9
- s.date = %q{2010-05-21}
9
+ s.date = %q{2010-05-29}
10
10
  s.description = %q{Provides a simple way to add rating functionality to your application.}
11
11
  s.email = %q{edgar.js@gmail.com}
12
12
  s.extra_rdoc_files = ["CHANGELOG", "README.textile", "lib/ajaxful_rating.rb", "lib/axr/css_builder.rb", "lib/axr/errors.rb", "lib/axr/helpers.rb", "lib/axr/locale.rb", "lib/axr/model.rb", "lib/axr/stars_builder.rb"]
data/lib/axr/model.rb CHANGED
@@ -21,7 +21,7 @@ module AjaxfulRating # :nodoc:
21
21
  has_many :rates_without_dimension, :as => :rateable, :class_name => 'Rate',
22
22
  :dependent => :destroy, :conditions => {:dimension => nil}
23
23
  has_many :raters_without_dimension, :through => :rates_without_dimension, :source => :rater
24
-
24
+
25
25
  options[:dimensions].each do |dimension|
26
26
  has_many "#{dimension}_rates", :dependent => :destroy,
27
27
  :conditions => {:dimension => dimension.to_s}, :class_name => 'Rate', :as => :rateable
@@ -36,12 +36,12 @@ module AjaxfulRating # :nodoc:
36
36
  :cache_column => :rating_average
37
37
  }
38
38
  end
39
-
39
+
40
40
  alias_method :ajaxful_rating_options, :axr_config
41
41
  end
42
-
42
+
43
43
  axr_config.update(options)
44
-
44
+
45
45
  include AjaxfulRating::InstanceMethods
46
46
  extend AjaxfulRating::SingletonMethods
47
47
  end
@@ -54,7 +54,7 @@ module AjaxfulRating # :nodoc:
54
54
 
55
55
  # Instance methods for the rateable object.
56
56
  module InstanceMethods
57
-
57
+
58
58
  # Proxy for axr_config singleton method.
59
59
  def axr_config
60
60
  self.class.axr_config
@@ -84,11 +84,11 @@ module AjaxfulRating # :nodoc:
84
84
  rate.save!
85
85
  self.update_cached_average(dimension)
86
86
  end
87
-
87
+
88
88
  # Builds the DOM id attribute for the wrapper in view.
89
89
  def wrapper_dom_id(options = {})
90
90
  options = options.symbolize_keys.slice(:small, :dimension)
91
- options = options.select { |k, v| v.present? }.map do |k, v|
91
+ options = options.select { |k, v| v.present? or (v == false) }.map do |k, v|
92
92
  if k == :dimension
93
93
  v.to_s
94
94
  else
@@ -106,13 +106,13 @@ module AjaxfulRating # :nodoc:
106
106
  def raters(dimension = nil)
107
107
  sql = "SELECT DISTINCT u.* FROM #{self.class.user_class.table_name} u "\
108
108
  "INNER JOIN rates r ON u.id = r.rater_id WHERE "
109
-
109
+
110
110
  sql << self.class.send(:sanitize_sql_for_conditions, {
111
111
  :rateable_id => id,
112
112
  :rateable_type => self.class.base_class.name,
113
113
  :dimension => (dimension.to_s if dimension)
114
114
  }, 'r')
115
-
115
+
116
116
  self.class.user_class.find_by_sql(sql)
117
117
  end
118
118
 
@@ -125,7 +125,7 @@ module AjaxfulRating # :nodoc:
125
125
  def rated_by?(user, dimension = nil)
126
126
  !rate_by(user, dimension).nil?
127
127
  end
128
-
128
+
129
129
  # Returns whether or not the user can rate this object.
130
130
  # Based on if the user has already rated the object or the
131
131
  # :allow_update option is enabled.
@@ -181,7 +181,7 @@ module AjaxfulRating # :nodoc:
181
181
  end
182
182
 
183
183
  module SingletonMethods
184
-
184
+
185
185
  # Maximum value accepted when rating the model. Default is 5.
186
186
  #
187
187
  # Change it by passing the :stars option to +ajaxful_rateable+
@@ -195,7 +195,7 @@ module AjaxfulRating # :nodoc:
195
195
  def user_class_name
196
196
  Rate.reflect_on_association(:rater).options[:class_name]
197
197
  end
198
-
198
+
199
199
  # Gets the user's class
200
200
  def user_class
201
201
  user_class_name.constantize
@@ -225,13 +225,13 @@ module AjaxfulRating # :nodoc:
225
225
  def find_statement(attr_name, attr_value, dimension = nil)
226
226
  sql = "SELECT DISTINCT r2.* FROM rates r1 INNER JOIN "\
227
227
  "#{self.base_class.table_name} r2 ON r1.rateable_id = r2.id WHERE "
228
-
228
+
229
229
  sql << sanitize_sql_for_conditions({
230
230
  :rateable_type => self.base_class.name,
231
231
  attr_name => attr_value,
232
232
  :dimension => (dimension.to_s if dimension)
233
233
  }, 'r1')
234
-
234
+
235
235
  find_by_sql(sql)
236
236
  end
237
237
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 2
8
- - 5
9
- version: 2.2.5
8
+ - 6
9
+ version: 2.2.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Edgar J. Suarez
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-21 00:00:00 -05:00
17
+ date: 2010-05-29 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies: []
20
20