Skip to content

Instantly share code, notes, and snippets.

@Mk-Etlinger
Created February 22, 2018 05:38
Show Gist options
  • Save Mk-Etlinger/252495d837b0f92444eb3f69ae1bbb0a to your computer and use it in GitHub Desktop.
Save Mk-Etlinger/252495d837b0f92444eb3f69ae1bbb0a to your computer and use it in GitHub Desktop.
First attempt at metaprogramming set_instance_variable method
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def after_sign_in_path_for(resource)
request.env['omniauth.origin'] || dashboard_path
end
def index
render "landing/index"
end
# this is an attempt to metaprogram the instance var. based on controller
# def set_instance_variable
# controller_name = params['controller']
# controller_name.chop!
# model_name = controller_name.capitalize
# instance_variable_set('@' + controller_name, model_name.find_by(id: params[:id]))
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment