Giter Club home page Giter Club logo

letsrate's People

Contributors

klaustrainer avatar microweb10 avatar muratguzel avatar murrekatt avatar petehuang avatar skyeagle avatar styx avatar thekindofme avatar wazery avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

letsrate's Issues

Display number of ratings

It would be great to be able to see how many users submitted a rating. How might you propose someone handle that?

Migration error on "rails g letsrate user"

/letsrate_generator.rb:37:in `create_migration': wrong number of arguments (3 for 0) (ArgumentError)

gem 'rails', '4.1.0'
I have installed devise with user model. I got this error in rails 4 and letsrate version 1.0.9 while applying this command
"rails g letsrate user".

Can you help me to solve this problem?

update_rate_average calculation mismatch in model.rb

Hi!,

The function update_rate_average has a little issue in the calculation, average decrease while the quantity of votes increase.

Line 30 in letsrate/lib/letsrate/model.rb:
'a.avg = (a.avg + stars) / (a.qty+1)'

...should be:
'a.avg = (a.avg*a.qty + stars) / (a.qty+1)'

to take in account the number of votes that have the average in dividend... Maybe this calculation can be done in different way but with this it works.

Thanks!

Impossible to turn off disable disable_after_rate

The appropriate instruction to do so is
disable_after_rate = options[:disable_after_rate] || true

But as you can see (options[:disable_after_rate] || true) will still be true if you set options[:disable_after_rate] = false

Undefined variable 'current_user'

I added this gem to my rails application and got the error: "Undefined variable 'current_user'".
is there a way to fix this? I already did 'db:migrate' as well

[feature request] Allow users to change the rating

Normally the users should be allowed to change their rating, for instance they can click on the rating they don't actually want by mistake.

Right now, if the user do this, letsrate raises an exception saying "User has already rated.".

By the way, great gem! I think it's the only rating gem working in rails3 that works without any hack, just following the documentation :) Congrats!

show the stars on index

Hi thank you for a great gem. A question please.
How do I display stars on the index page of model? It trows an error
undefined methodaverage' for nil:NilClass`

It's OK on the show page tho

Also a small bag during the installation it generates two migration files with the same name, rails is refusing to migrate, I had to manually rename one of the files

Show ratings stats

Is there a way to show rating stats like what's on Amazon.come? For example.

5 stars: ********** ( 10)
4 stars: **** ( 4)
3 stars: * ( 1)
2 stars: ** ( 2)
1 stars: ** ( 2)

Rails-4.0.2 and MySql with server error 500 and attr-accessible deprecated

Hello,

I find two other problem resolved like this:

1 on rate.rd model file, change attr_accessible by attr_accessor
2 on rater_controller.rb, just before last "end" class call, add :
private
def set_obj
@obj= (ligne 7 copie/paste eval line)
end
def obj_params
params.require(:rater).permit(:klass, :stars, :dimension, :score, :rate)
end
then, take off the ligne 7 (obj=eval.....)
and add "before_action :set_obj, only: [:create]" just after class declaration

(this was for strong_parameter process for rails-4)

3 on gem file of letsrate (model.rb)
change:
line 9:
r.rater_id = user_id.id (and not user_id)
line 45:
......and rater_id=#{user_id.id}...... (and note user_id)

this will work good and not make error 500 server for mysql. Also, no more warning for strong_parameter in rails-4

I try to find a way for call "klass" controller without "eval" ruby function...

losing rating capability after ajax load

Let me first start by saying "Great gem".

On my page, I use your star rating but the user can click on a link to update a div element using ajax.
After the ajax load, all of the javascript for the star rating breaks.

I've been using the jquery "on" event for other javascript functions that I have created but I don't know how to use to fix the star rating.

How can I reload letsrate.js.erb and jquery.raty.js after an ajax load?

deprecation warning when running rails console for associations

I am using the letsrate gem in Rails 4 application. I have added the gem into my lib file and changed it a bit for making it to work with Rails 4. Now I am getting a deprecated warning like this:

DEPRECATION WARNING: The following options in your Performer.has_many :rates_without_dimension declaration are deprecated: :conditions. Please use a scope block instead. For example, the following:

has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'

should be rewritten as the following:

has_many :spam_comments, -> { where spam: true }, class_name: 'Comment' . (called from letsrate_rateable at /home/aravind/Documents/dev/gw-c4u/lib/letsrate/lib/letsrate/model.rb:76) DEPRECATION WARNING: The following options in your Performer.has_one :rate_average_without_dimension declaration are deprecated: :conditions. Please use a scope block instead. For example, the following:

has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'

should be rewritten as the following:

has_many :spam_comments, -> { where spam: true }, class_name: 'Comment' . (called from letsrate_rateable at /home/aravind/Documents/dev/gw-c4u/lib/letsrate/lib/letsrate/model.rb:79) DEPRECATION WARNING: The following options in your Performer.has_many :performance_rates declaration are deprecated: :conditions. Please use a scope block instead. For example, the following:

has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'

should be rewritten as the following:

has_many :spam_comments, -> { where spam: true }, class_name: 'Comment' . (called from block in letsrate_rateable at /home/aravind/Documents/dev/gw-c4u/lib/letsrate/lib/letsrate/model.rb:84) DEPRECATION WARNING: The following options in your Performer.has_one :performance_average declaration are deprecated: :conditions. Please use a scope block instead. For example, the following:

has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'

should be rewritten as the following:

has_many :spam_comments, -> { where spam: true }, class_name: 'Comment' . (called from block in letsrate_rateable at /home/aravind/Documents/dev/gw-c4u/lib/letsrate/lib/letsrate/model.rb:91)

The part of the file which generates such an error is this:

module ClassMethods

def letsrate_rater
  has_many :ratings_given, :class_name => "Rate", :foreign_key => :rater_id       
end    

def letsrate_rateable(*dimensions)
  has_many :rates_without_dimension, :as => :rateable, :class_name => "Rate", :dependent => :destroy, :conditions => {:dimension => nil}
  has_many :raters_without_dimension, :through => :rates_without_dimension, :source => :rater  

  has_one :rate_average_without_dimension, :as => :cacheable, :class_name => "RatingCache", 
      :dependent => :destroy, :conditions => {:dimension => nil}


  dimensions.each do |dimension|        
    has_many :"#{dimension}_rates", :dependent => :destroy, 
                               :conditions => {:dimension => dimension.to_s}, 
                               :class_name => "Rate", 
                               :as => :rateable

    has_many :"#{dimension}_raters", :through => "#{dimension}_rates", :source => :rater         

    has_one :"#{dimension}_average", :as => :cacheable, :class_name => "RatingCache", 
                                :dependent => :destroy, :conditions => {:dimension => dimension.to_s}
  end                                                    
end

I have tried bringing the :dependent=>:destroy to the last part of the line and changing conditions => {:dimension => dimension.to_s} to -> {:dimension => dimension.to_s}. It only throws errors. What am I doing wrong?

Object remains votable via JQuery after vote is placed

Not sure if this is a Rails 3.2 asset pipeline issue or what, but after placing a vote (the POST action happens fine), the javascript to be able to vote is still live and active. I am able to continue clicking stars, and in the console the model displays the "user already voted" error logs.

Jquery should be disabling the voting ability after a vote is cast, right?

No method 'raty'

Hello.

I have followed your instructions and I get this error in the browser console and the star ratings aren't displayed:

Uncaught TypeError: Object [object Object] has no method 'raty' letsrate.js:5
(anonymous function) letsrate.js:5
fire jquery.js:975
self.fireWith jquery.js:1085
jQuery.extend.ready jquery.js:407
DOMContentLoaded

Heroku deployment error

Hi,
I just uninstalled letsrate gem, and removed all the migration genreated by letsrate but still getting the following error when deploying on heroku.

screen shot 2013-08-05 at 12 45 05 pm

Please help out here.
Thank you all

letsrate only compatible with rails 4?

Seems like rails 3 doesn't like the "-> { where dimension: nil}" syntax in letsrate_rateable.
I wish there were some brunch supporting previous versions of rails...

NoMethodError caught when I'm trying destroy the rated object

I've decided using gem letsrate in my app, but I have some problem, probably caused by gem.

First some code:

I've got a model Article:

class Article < ActiveRecord::Base
  letsrate_rateable "quality"
  ...
end

and model User (generated by Devise):

class User < ActiveRecord::Base
  letsrate_rater
  ...
end

I've used generator according to readme instructions:

rails g letsrate user

Everything works great until I try destroy my article object, then I've got this error:

>> Article.last.destroy
Article Load (0.4ms)  SELECT `articles`.* FROM `articles` ORDER BY `articles`.`id` DESC LIMIT 1
   (0.1ms)  BEGIN
  Rate Load (0.4ms)  SELECT `rates`.* FROM `rates` WHERE `rates`.`rateable_id` = 1 AND `rates`.`rateable_type` = 'Article' AND `rates`.`dimension` IS NULL
  SQL (0.3ms)  DELETE FROM `rates` WHERE `rates`.`id` = 2
  RatingCache Load (1.2ms)  SELECT `rating_caches`.* FROM `rating_caches` WHERE `rating_caches`.`cacheable_id` = 1 AND `rating_caches`.`cacheable_type` = 'Article' AND `rating_caches`.`dimension` IS NULL LIMIT 1
  SQL (1.0ms)  DELETE FROM `rating_caches` WHERE `rating_caches`.`id` = 2
  Rate Load (0.3ms)  SELECT `rates`.* FROM `rates` WHERE `rates`.`rateable_id` = 1 AND `rates`.`rateable_type` = 'Article' AND `rates`.`dimension` = 'quality'
  Rate Load (0.3ms)  SELECT `rates`.* FROM `rates` WHERE `rates`.`rateable_id` = 1 AND `rates`.`rateable_type` = 'Article' AND `rates`.`dimension` = 'quality'
   (0.5ms)  ROLLBACK
NoMethodError: undefined method `association_class' for nil:NilClass
  from /Users/xyz/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.1.6/lib/active_record/associations.rb:159:in `association'
from /Users/xyz/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.1.6/lib/active_record/associations/builder/has_one.rb:49:in `has_one_dependent_destroy_for_quality_average'
  from /Users/xyz/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.6/lib/active_support/callbacks.rb:422:in `_run_destroy_callbacks'
  from /Users/xyz/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.6/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /Users/xyz/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.1.6/lib/active_record/callbacks.rb:254:in `destroy'
  from /Users/xyz/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.1.6/lib/active_record/transactions.rb:236:in `block in destroy'
  from /Users/xyz/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.1.6/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
from /Users/xyz/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:194:in `transaction'
  from /Users/xyz/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.1.6/lib/active_record/transactions.rb:208:in `transaction'
  from /Users/xyz/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.1.6/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
from /Users/xyz/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.1.6/lib/active_record/transactions.rb:236:in `destroy'
  from (irb):1
  from /Users/xyz/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.6/lib/rails/commands/console.rb:45:in `start'
  from /Users/xyz/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.6/lib/rails/commands/console.rb:8:in `start'
from /Users/xyz/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.6/lib/rails/commands.rb:40:in `<top (required)>'
  from /Users/xyz/projekty/dentist/script/rails:6:in `require'
  from /Users/xyz/projekty/dentist/script/rails:6:in `<top (required)>'
from -e:1:in `load'
  from -e:1:in `<main>'

The error occures no matter if I use quality dimension or not. I will be very grateful for your reply where the problem is.

PS. Im'using the newest version of gem (letsrate (1.0.7))

Single Table Inheritance support

I have two models:

class Resource
end

class Tutorial < Resource
  letsrate_rateable "name"
end

When I rate a Tutorial, RatingCache saves the correct type (Tutorial):

=> #<RatingCache id: 41, cacheable_id: 9, cacheable_type: "Tutorial", avg: 3.0, qty: 1, dimension: "name", created_at: "2014-03-12 05:06:09", updated_at: "2014-03-12 05:06:09">

However, when I call the average method in the Letsrate module, it searches for RatingCaches of the parent class (Resource), not the child class (Tutorial). In other words, when I call self.send("#{dimension}_average"), I get this SQL:

RatingCache Load (0.2ms)  SELECT  "rating_caches".* FROM "rating_caches"  WHERE "rating_caches"."cacheable_id" = $1 AND "rating_caches"."cacheable_type" = $2 AND "rating_caches"."dimension" = 'name'  ORDER BY "rating_caches"."id" ASC LIMIT 1  [["cacheable_id", 9], ["cacheable_type", "Resource"]] => nil

What needs to be changed so when saving and retrieving RatingCaches, the cacheable_type matches (either Tutorial or Resource)?

How to get average from all users

How would I get the average rating from all users for each attribute and also the average overall rating from all attributes? Also, is it possible to show a numerical value instead of the stars?

Cannot precompile assets

$ rake assets:precompile RAILS_ENV=production
c:/Ruby193/bin/ruby.exe c:/Ruby193/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=ass
rake aborted!
undefined method `rate_path' for #Module:0x39accc8
(in C:/MYAPP/app/assets/javascripts/letsrate.js.erb)

which is this line =>
$.post('<%= Rails.application.class.routes.url_helpers.rate_path %>',

Rails 3.2.6
Ruby 1.9.3
Windows 7
letsrate 1.0.7

You can check my repository:

https://github.com/algritz/Livre_recette_v3

Lets Rate gem with field_for

I am new to letsrate gem and also saw existing bugs. No one post the issue like this. In order to avoid ajax call, I am customized letsrate.js.erb for form submission. Setting the values of letsrate scores, dimensions and klass in hidden fields. Till now everything works fine for me.

In Review model:
letsrate_rateable "speed"

In letsrate.js.erb:
click: function(score, evt) {
var _this = this;
$("#business_rate_score").attr("value", score);
$("#business_rate_dimension").attr("value", $(this).attr('data-dimension'));
$("#business_rate_klass").attr("value", $(this).attr('data-classname'));
}
When am trying to use field_for and use those hidden fields like this:
<%= f.fields_for :rates do |g| %>
input type='hidden' id="business_rate_score" name="score"
input type='hidden' id="business_rate_dimension" name="dimension"
input type='hidden' id="business_rate_klass" name="klass"
<% end %>

For making nested_attributes in Review model:
letsrate_rateable "speed"
accepts_nested_attributes_for :rates, :allow_destroy => true

It throws No association found for name `rates'. Has it been defined yet? (ArgumentError)

Is letsrate gem accepting nested attributes? Can you explain me to make nested attributes to save the values?

RailsAdmin & letsrate Error (Rails4)

After installation of letsrate
when I'm trying to edit any of my model in RailsAdmin I get

ActiveRecord::Reflection::ThroughReflection#foreign_key delegated to source_reflection.foreign_key, but source_reflection is nil

but in general letsrate works!

it can not work after adding readOnly option

In letsrate.js.erb:

$(function(){ 
    $(".star").raty({                  
        score: function(){
            return $(this).attr('data-rating')              
        }, 
        number: function() {
            return $(this).attr('data-star-count')
        },
        readOnly: function() {
            //console.log('sss')
            return false;//$(this).attr('data-readonly') == 'true'      
        },
        click: function(score, evt) {
            $.post('<%= Rails.application.class.routes.url_helpers.rate_path %>', 
                {
                    score: score, 
                    dimension: $(this).attr('data-dimension'),  
                    id: $(this).attr('data-id'),
                    klass: $(this).attr('data-classname')
                }, 
                function(data) {
                    if(data) {
                        // success code goes here ... 
                    }
            });
        }                        
    });           
});

If I add readOnly option , no matter it is true or false, the star can not be clicked.

rate_for_user with dimension give zero length bar

I use the rate_for_user for dimension like below

" rating_for_user ratable, user, r"

it works if user already given rates to the dimension.

But it just display an zero length bar for dimension i haven't rated.

Thanks!

Displaying User Ratings

Is there a way to display the rating(s) a user submitted?

For example, the rating_for helper only displays the average rating from a collection of users but I would like to be able to display the individual ratings that the user submitted as well (not the averages).

POST fails. Is this a routes issue?

POST http://localhost:3000/rate 500 (Internal Server Error) jquery.js:8417
send jquery.js:8417
jQuery.extend.ajax jquery.js:7969
jQuery.(anonymous function) jquery.js:7496
$.raty.click letsrate.js:13
(anonymous function) jquery.raty.js:185
jQuery.event.dispatch jquery.js:3064
elemData.handle.eventHandle jquery.js:2682

Any idea if this is a routes issue? I didn't see a specific route needed in the readme. Should there be one?

Thanks,
Joe

letsrate -- the stars are not displayed :(

I am using rails 3.2.8 gem, ruby 1.9.3 and want to add star rating to my project. I am using the letsrate gem. The stars are not displayed. I know this is something to do either with .js or the .css files. There is no .css file though for this gem. The jquery.raty.js and letsrate.js.erb files are in app/assets/javascripts directory.The star images are in app/assets/images directory.In my /show.html.erb file I wrote:

     <% content_for :javascript_includes do %>
     <%= javascript_include_tag 'jquery.raty.js','letsrate.js.'%>
     <% end %>    
    <dd>Quality : <%= rating_for @book, "quality",:star => 5 %><br/>
   Value For Money : <%= rating_for @book, "value_for_money",:star => 5  %><br/>
   Price : <%= rating_for @book, "price", :star => 5 %></dd><br/>
Im my views/layout/application.html.erb file I wrote:
<html>
<head>
    <title><%=@page_title || '*** T&T ***'%></title>
    <%= javascript_include_tag 'application'%>
   <%= yield :javascript_includes %>            
   <%= stylesheet_link_tag 'style','application', media: "all"%>
    <%= csrf_meta_tags %>
When application runs, the stars are not displayed. Do I need to write .css file? I am really, really in dire need of your help!!! Thank you.

Routes with match and without an HTTP method are deprecated in Rails 4

Awesome gem, thanks for your hard work guys!

Rails 4 doesn't like routes that start with match and don't have the HTTP method(s) specified. Maybe something you could change in the source code for future use. Is it only get or both get and post?

get '/rate' => 'rater#create', :as => 'rate' OR
match '/rate', to: 'rater#create', :as => 'rate', via: [:get, :post]'

Thx

migu at Laptop in ~/Projects/zookal-digital on master
$ rails g letsrate User
      create  app/assets/javascripts/jquery.raty.js
      create  app/assets/images/star-on.png
      create  app/assets/images/star-off.png
      create  app/assets/images/star-half.png
      create  app/assets/javascripts/letsrate.js.erb
      create  app/controllers/rater_controller.rb
      create  app/models/rate.rb
      create  app/models/rating_cache.rb
       route  match '/rate' => 'rater#create', :as => 'rate'
      create  db/migrate/20140102015045504_create_rating_caches.rb
      create  db/migrate/20140102015045505_create_rates.rb
migu at Laptop in ~/Projects/zookal-digital on master*
$ rake db:migrate
[RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
rake aborted!
You should not use the `match` method in your router without specifying an HTTP method.
If you want to expose your action to both GET and POST, add `via: [:get, :post]` option.
If you want to expose your action to GET, use `get` in the router:
  Instead of: match "controller#action"
  Do: get "controller#action"
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:191:in `normalize_conditions!'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:67:in `initialize'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1443:in `new'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1443:in `add_route'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1422:in `decomposed_match'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1403:in `block in match'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1394:in `each'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1394:in `match'
/Users/migu/Projects/zookal-digital/config/routes.rb:2:in `block in <top (required)>'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `instance_exec'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `eval_block'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:319:in `draw'
/Users/migu/Projects/zookal-digital/config/routes.rb:1:in `<top (required)>'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `each'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:16:in `reload!'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `call'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `execute'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:27:in `updater'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/migu/Projects/zookal-digital/config/environment.rb:5:in `<top (required)>'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/application.rb:189:in `require_environment!'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/gems/railties-4.0.2/lib/rails/application.rb:250:in `block in run_tasks_blocks'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/bin/ruby_executable_hooks:15:in `eval'
/Users/migu/.rvm/gems/ruby-2.0.0-p247@zookal-digital/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

`has_many': wrong number of arguments (3 for 2) (ArgumentError)

I followed the README and tried implementing this gem. Created all the necessary models, ran the generators and migrated the databases. Added necessary lines in User model and Conference model.

letsrate generator for User model. Here user model is devise generated model

rails g letsrate User

create  app/assets/javascripts/jquery.raty.js
      create  app/assets/images/star-on.png
      create  app/assets/images/star-off.png
      create  app/assets/images/star-half.png
      create  app/assets/javascripts/letsrate.js.erb
      create  app/controllers/rater_controller.rb
      create  app/models/rate.rb
      create  app/models/rating_cache.rb
       route  post '/rate' => 'rater#create', :as => 'rate'
      create  db/migrate/20140304180848_create_rating_caches.rb
      create  db/migrate/20140304180849_create_rates.rb

$ rake db:migrate
==  CreateRatingCaches: migrating =============================================
-- create_table(:rating_caches)
   -> 0.0015s
-- add_index(:rating_caches, [:cacheable_id, :cacheable_type])
   -> 0.0007s
==  CreateRatingCaches: migrated (0.0025s) ====================================

==  CreateRates: migrating ====================================================
-- create_table(:rates)
   -> 0.0026s
-- add_index(:rates, :rater_id)
   -> 0.0012s
-- add_index(:rates, [:rateable_id, :rateable_type])
   -> 0.0012s
==  CreateRates: migrated (0.0054s) ===========================================


#app/model/user.rb
class User < ActiveRecord::Base
  include PublicActivity::Common
  recommends :conferences
  letsrate_rater
.
.
end

#app/model/conference.rb
class Conference < ActiveRecord::Base
  searchkick autocomplete: ['subject']
  include PublicActivity::Common
  letsrate_rateable "quality"
.
.
end

So have prepared my app as per the instructions given in the README.
now when I run the rails server I get the following error.

/home/shivakumaarmgs/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.9/lib/active_record/associations.rb:1197:in `has_many': wrong number of arguments (3 for 2) (ArgumentError)
    from /home/shivakumaarmgs/.rvm/gems/ruby-1.9.3-p484/gems/letsrate-1.0.9/lib/letsrate/model.rb:87:in `letsrate_rateable'
    from /home/shivakumaarmgs/Rails/talkingslate/app/models/conference.rb:5:in `<class:Conference>'
    from /home/shivakumaarmgs/Rails/talkingslate/app/models/conference.rb:1:in `<top (required)>'
    from /home/shivakumaarmgs/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:469:in `load'
    from /home/shivakumaarmgs/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:469:in `block in load_file'
and it goes on

What am I doing wrong

ruby version 1.9.3
rails version 3.2.9

Rake rollback and redo broken

Since I installed letsrate, my rake db:migrate:redo or rake db:rollback will only redo or rollback the migration for letsrate.

I am obviously losing all the rating data after any attempt of redo or rollback of the last migration on my database.

I detailed the problem on stackoverflow, http://stackoverflow.com/questions/14711908/rake-dbrollback-reverting-the-wrong-migration

My feelings is the install of the gem broke something in my setup, and I don't know how to fix it.

Any suggestion is most welcome.

Cheers,

joel

Unable to rollback !

Dears,

I was trying the gem letsrate

Now I am trying to remove it
using :
rake db:rollback
rails d letsrate user

but after that when I try to access the book show page
it says :
rate is defined by ActiveRecord
ActiveRecord::DangerousAttributeError in Books#show

any solution ?
It is refusing this following :
<%= review.rate %>

Thank you

rating_for_user with disable_after_rate => true get `ratings_given' for 22:Fixnum error

my call
" rating_for_user ratable, user, r, :disable_after_rate => true"

gives the following errors, which disappear without the disable_after_rate

undefined method `ratings_given' for 22:Fixnum

Extracted source (around line #18):

15: %lable=t("activerecord.attributes.rating.#{r}")
16: .rating_wrapper
17: - if user.present?
18: = rating_for_user ratable, user, r, :disable_after_rate => true
19: - else
20: = rating_for ratable, r, :disable_after_rate => true
21:

Application Trace | Framework Trace | Full Trace

app/views/ratings/_ratable.haml:18:in block in _app_views_ratings__ratable_haml___940430013_100816650' app/views/ratings/_ratable.haml:13:ineach'
app/views/ratings/_ratable.haml:13:in _app_views_ratings__ratable_haml___940430013_100816650' app/views/students/opinions/_nav_bar.haml:19:in_app_views_students_opinions__nav_bar_haml___121796833_107698390'
app/views/students/opinions/show.html.haml:15:in _app_views_students_opinions_show_html_haml__499083187_105337980' app/controllers/students/opinions_controller.rb:16:inshow'

Found issue in can_rate? method

There is a issue with can_rate? method, It's sql query when dimension is nil was:

"select count(*) as cnt from rates where rateable_id=33 and rateable_type='ABC' and rater_id=2 and dimension=''

instead of

"select count(*) as cnt from rates where rateable_id=33 and rateable_type='ABC' and rater_id=2 and dimension is null"

Please have a look and take a appropriate action to resolve the issue.

Thanks in advance.

How to eager load rating_caches?

I have tried many different ways to eager load the rating caches for a users items. But can't seem to get it right. Can you please suggest?

RatingCache Load (0.3ms) SELECT "rating_caches".* FROM "rating_caches" WHERE "rating_caches"."cacheable_id" = $1 AND "rating_caches"."cacheable_type" = $2 AND "rating_caches"."dimension" IS NULL ORDER BY "rating_caches"."id" ASC LIMIT 1 [["cacheable_id", 89], ["cacheable_type", "Item"]]

(0.3ms) SELECT COUNT(*) FROM "rates" WHERE "rates"."rater_id" = $1 AND (("rates"."dimension" IS NULL AND "rates"."rateable_id" = 89 AND "rates"."rateable_type" = 'Item')) [["rater_id", 52]]

RatingCache Load (0.3ms) SELECT "rating_caches".* FROM "rating_caches" WHERE "rating_caches"."cacheable_id" = $1 AND "rating_caches"."cacheable_type" = $2 AND "rating_caches"."dimension" IS NULL ORDER BY "rating_caches"."id" ASC LIMIT 1 [["cacheable_id", 87], ["cacheable_type", "Item"]]

(0.4ms) SELECT COUNT(*) FROM "rates" WHERE "rates"."rater_id" = $1 AND (("rates"."dimension" IS NULL AND "rates"."rateable_id" = 87 AND "rates"."rateable_type" = 'Item')) [["rater_id", 52]]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.