Skip to content

Instantly share code, notes, and snippets.

@cbeier
Created January 7, 2010 10:26
Show Gist options
  • Save cbeier/271149 to your computer and use it in GitHub Desktop.
Save cbeier/271149 to your computer and use it in GitHub Desktop.
find polymorphic
# controller
private
def find_polymorphic
params.each do |name, value|
if name =~ /(.+)_id$/
return $1.classify.constantize.find(value)
end
end
nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment