Skip to content

Instantly share code, notes, and snippets.

@Mk-Etlinger
Created February 22, 2018 02:38
Show Gist options
  • Select an option

  • Save Mk-Etlinger/a8b05c40b5c8cd53e356e744faf8540f to your computer and use it in GitHub Desktop.

Select an option

Save Mk-Etlinger/a8b05c40b5c8cd53e356e744faf8540f to your computer and use it in GitHub Desktop.
def sorcery
controller_name = params['controller']
controller_name.chop!
model_name = controller_name.capitalize
instance_variable_set('@' + controller_name, Object.const_get( model_name ).find_by(id: params[:id]))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment