edgarjs / ajaxful-rating

Provides a simple way to add rating functionality to your application.
http://rdoc.info/projects/edgarjs/ajaxful-rating
417 stars 127 forks source link

jQuery version with Rails3 #55

Closed millisami closed 13 years ago

millisami commented 13 years ago

Since I'm using jQuery and Rails3, this piece of controller code is not updated in the README

render :update do |page|
  page.replace_html @car.wrapper_dom_id(params), ratings_for(@car, params.merge(:wrap => false))
  page.visual_effect :highlight, @car.wrapper_dom_id(params)
end

So, I created a custom .js.erb file but I'm confused what that .wrapper_dom_id(params) method returns? Can you plz add a jquery version of the above render :update do |page| code block?

edgarjs commented 13 years ago

The plugin is javascript framework agnostic, which means it doesn't really require you to use jquery or prototype. It's using rails helper.

The wrapper_dom_id simply concatenates the passed params to return an id.

jspooner commented 13 years ago

In rails 3.1 RJS has been removed so my controller now looks like this.


  def rate
    @location = Location.find(params[:id])
    @location.rate(params[:stars], current_user, params[:dimension])
    respond_to do |format|
        format.js { render :partial => "rating" }
    end
  end

and _rating.html.erb

<%= ratings_for @location, current_user %>
tonyrobots commented 13 years ago

Jspooner, why the conditional in that? Looks like it does the same thing either way?