Created
September 21, 2011 20:44
-
-
Save josephruscio/1233251 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MetricsController < ApplicationController | |
before_filter :find_metric | |
respond_to :html, :json | |
def edit | |
if admin_signed_in? | |
@user = metric.user | |
end | |
respond_with(metric) | |
end | |
def destroy | |
metric.deleted_time = time_now_in_ms | |
metric.save! | |
#XXX: Hack that works as long we can only delete metrics from the home page | |
respond_with(metric, :location => root_url) | |
end | |
protected | |
def metric_scope | |
raise NotImplementedError | |
end | |
def metric! | |
@metric = metric_scope.active.where(:name => params[:id]).first | |
@metric.blank? ? render_404 : @metric | |
end | |
def metric | |
@metric ||= metric! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment