Steve Thomas
Steve Thomas

Reputation: 47

Ajaxful-rating confirmation when casting vote - ruby on rails

I'm running an app that uses Ajaxful-rating with Rails 3 right now, but several users have commented that it is tough to tell if you've actually voted.

Ideally I'd like a small growl-ish window to appear that says "Thanks!" or "rated!" or something like that when a user votes, however I cannot make this work.

Any ideas?

Here's the controller code for rating:

def rate
  @idea = Idea.find(params[:id])
  @idea.rate(params[:stars], current_user, params[:dimension])

  average = @idea.rate_by(current_user, :quality).stars
  width   = average.to_f / @idea.class.max_stars * 100

  render :json => { :id       => @idea.wrapper_dom_id(params),
                    :average  => average,
                    :width    => width
                  }
end

Thanks in advance.

Upvotes: 1

Views: 227

Answers (1)

Jordan Running
Jordan Running

Reputation: 106017

You say you "cannot make this work" but it's unclear what you've tried. Does your controller method work? What does your client-side code look like? If you're successfully making the Ajax call then all you need to do is, on the client side, handle the Ajax response you get and show your message.

As for a "small Growl-ish window" there are lots of libraries out there that do this kind of thing, or you could roll your own.

Upvotes: 1

Related Questions