-
Notifications
You must be signed in to change notification settings - Fork 0
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
Undefined method NoMethodError average #1
Comments
You’ll find that average is a relation defined in the concern: https://github.com/malagant/mongoid-letsrate/blob/master/lib/mongoid/letsrate/model.rb#L78 An 24. Februar 2014 at 08:33:31, railskipl ([email protected]://[email protected]) schrieb: I am getting following error while rating def update_rate_average(stars) I am not getting, where average method is defined? — |
But still, I am not able to understand why it giving error.. at |
I checked in the rails console and can't reproduce the error? Which mongoid gem version do you use? How do you create the rating? Pleas provide more details and I will be happy to support you. |
sorry, found the bug. Please wait for a fix. |
thanks.. also I've encounter one issue :
When I am inspecting |
A fix for "average" is now in the repo and I released a new gem. I swear, that I will provide tests i the next release. ;) |
For your second problem. The code works if you run it in the right context. E.g. I tried it in the rails console and found out, that the rateable_type could be Object in your example. If you use the right one, it returns correct values. Am I right? |
First time when I rate it rates properly, but then again I rate ,it is not displaying rating. For example when I am rating 5 stars by [email protected](say) first time it rates properly then again I try to rate with 2 stars(same email) it should raise an error "User already rate" but it is not raising and it is not displaying the previous rating i.e. 5 stars also. Also I've tried the other way... I mean to say first I rate a car with [email protected] and then when I try to rate the same car with [email protected] I am not able to rate it when I refresh rating is gone for [email protected]. |
I've just now visited the rails console and found that when I rate first time say 2 stars avg. value in RatingCache is 2.0 but then again when I rate with another email with rating 5 stars, the avg. value is 0.0.
|
I've found that rater_id in user model is nil. When I try to update rater_id from console it is raising an error |
I've managed to find average as
|
I am currently writing the needed specs. I have to confess, that I did a quick and dirty write without any testing. I will provide something later this evening. Thank you for your patience. |
I am getting following error while rating
(undefined method `average' for #Mongoid::Criteria:0xb335e5b8)
I am not getting, where average method is defined?
The text was updated successfully, but these errors were encountered: