Skip to content

Instantly share code, notes, and snippets.

@rantler
Created November 5, 2013 23:41
Show Gist options
  • Save rantler/7328362 to your computer and use it in GitHub Desktop.
Save rantler/7328362 to your computer and use it in GitHub Desktop.
class PluginRater
def self.rate_plugin_for_user!(rating, plugin, user)
plugin.update_rating_for_user(rating, user)
Event::Publish('user_rated_a_plugin', rating, plugin, user)
Auditor::AuditRatingChange(rating, plugin, user)
end
end
class Controller
def rate
begin
PluginRater.rate_plugin_for_user!(params[:rating], @plugin, current_user)
rescue ActiveRecord::RecordInvalid => e
NewRelic::Agent.notice_error(e)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment