Skip to content

Instantly share code, notes, and snippets.

@josephruscio
Created September 21, 2011 20:44
Show Gist options
  • Save josephruscio/1233251 to your computer and use it in GitHub Desktop.
Save josephruscio/1233251 to your computer and use it in GitHub Desktop.
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