Rails controller method to accept one rating per IP address via AJAX
Controller code looks good.. You only need to refactor code little bit so that it will look more clean &amp; robust. otherwise rest things are ok. regarding ajax response, you need to implement success/failure response either inside controller or js file.

just to give idea on implementing ajax response inside controller

def update
  render :update do |page|
    if success
      # here replace_html is prototype helper method
      page.replace_html "DIV_ID", "PARTIAL"
      # if you are using jquery then you can execute js code like
      page &lt;&lt; "js code goes here"
    else
      page.replace_html "ERR_DIV", "Error occured"
    end
  end
end