Skip to content

Instantly share code, notes, and snippets.

@Centaur
Created May 1, 2012 14:39
Show Gist options
  • Save Centaur/2568390 to your computer and use it in GitHub Desktop.
Save Centaur/2568390 to your computer and use it in GitHub Desktop.
memory leak
class TalentsController < ApplicationController
PUBLICS = %w(screen presenter musical t_stage others)
layout :different_layout
# memory leak
def different_layout
if PUBLICS.tap { |a| a.concat(a.map { |s| s+'_preview' }) }.include?(action_name)
'talents'
else
'admin'
end
end
# no memory leak
def different_layout
previewed = PUBLICS.map{|s| s+'_preview'}
#if PUBLICS.tap { |a| a.concat(a.map { |s| s+'_preview' }) }.include?(action_name)
if previewed.include?(action_name) or PUBLICS.include?(action_name)
'talents'
else
'admin'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment