def show
@activity = sandbox.activity.find(params[:id])
scope = self
class << @activity; self; end.send(:define_method,
:allowed_actions) do
%w[play pause finish delete reject approve accept
decline take_back].select do |action|
scope.can?(action.to_sym, self)
end
end
end
Last active
December 26, 2015 05:09
-
-
Save JiriChara/7098705 to your computer and use it in GitHub Desktop.
Define singleton method on an object to make it available in view and do not extend object's meta class. Defined in flat scope to have access to the controller context.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment