I'm in a bit over my head with debugging ajax calls on this, wondering if anyone can help me out. I followed all the directions in the readme, the one tricky thing is my user model is both the rater and the one being rated, not sure if that makes a difference.
I'm rating across four dimensions, [:overall, :knowledgeable, :punctual, :friendly]... the stars show up on my feedback form, but my problem is that when I click to rate, it doesn't actually do anything to the DB, and when I click on another star rating the first one disappears. Looking at my server log, there is a clue:
Processing UsersController#1 (for 127.0.0.1 at XXXX) [POST]
Parameters: {"small"=>"false", "authenticity_token"=> "XXX", "id"=>"rate", "stars"=>"4", "dimension"=>"overall", "show_user_rating"=>"true"}
...
ActionController::UnknownAction (No action responded to 1. Actions: login, logout, rate)
For routes, I'm using the standard:
map.resources :users, :member => {:rate => :post}
Which works out to this in rake routes:
rate_user POST /users/:id/rate(.:format) {:controller=>"users", :action=>"rate"}
In the user model:
ajaxful_rateable :stars => 5, :dimensions => [:overall, :knowledgeable, :friendly, :punctual]
ajaxful_rater
In the users controller:
def rate
@ratee = User.find(params[:id])
@ratee.rate(params[:stars], @user, params[:dimension])
render :update do |page|
page.replace_html @ratee.wrapper_dom_id(params), ratings_for(@ratee, params.merge(:wrap => false))
page.visual_effect :highlight, @ratee.wrapper_dom_id(params)
end
In the view:
Overall: <%= ratings_for @invoice.ticket.winning_user, @user, :show_user_rating => true, :dimension => :overall %><br>
Knowledgeable: <%= ratings_for @invoice.ticket.winning_user, @user, :show_user_rating => true, :dimension => :knowledgeable %><br>
Friendly: <%= ratings_for @invoice.ticket.winning_user, @user, :show_user_rating => true, :dimension => :friendly %><br>
Punctual: <%= ratings_for @invoice.ticket.winning_user, @user, :show_user_rating => true, :dimension => :punctual %><br>
Any thoughts would be absolutely greatly appreciated! :)
EDIT:
I got it to work using a very ugly hack... I added:
:remote_options => { :url => "/users/rate/" + @invoice.ticket.winning_user.id.to_s}
to each of the ratings objects... can someone tell me what I was doing wrong and how I can make this work without using the above line?