Skip to content

Instantly share code, notes, and snippets.

@mclosson
Created September 7, 2011 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mclosson/1199816 to your computer and use it in GitHub Desktop.
Save mclosson/1199816 to your computer and use it in GitHub Desktop.
How to obtain the installable object from a polymorphic relationship
class InstallStepsController < ApplicationController
before_filter lambda {
if params[:release_id]
@installable = Release.includes(:product).find(params[:release_id])
elsif params[:virtual_machine_id]
@installable = VirtualMachine.find(params[:virtual_machine_id])
else
redirect_to root_url
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment