Sign in through GitHub

RailsCasts Pro episodes are now free!

Learn more or hide this

Constantine Georgiadis's Profile

GitHub User: RITF

Site: rightintheface.com

Comments by Constantine Georgiadis

Avatar

Hi @FlintMakal - how about this for nested resources instead?

ruby
  def find_commentable
    params.reverse_each do |name, value|
      if name =~ /(.+)_id$/
        return $1.classify.constantize.find(value)
      end
    end
    nil
  end