Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  def self.find(*args)
    permalink = args.first if argument_is_permalink?(args.first)
    
    if permalink
      show = find_by_permalink(args)
      
      if show then return show
      else 
        raise ActiveRecord::RecordNotFound, "Your first argument to Show.find was a permalink, but no Show could be found with a permalink of '#{permalink}'"
      end
    end
    
    super
  end
  
  private
  
  def self.argument_is_permalink?(argument)
    argument.is_a?(String) && argument.to_i.to_s != argument.to_s
  end