Skip to content

Instantly share code, notes, and snippets.

@timoschilling
Created October 9, 2015 05:08
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 timoschilling/c35b3eee7022e87c8027 to your computer and use it in GitHub Desktop.
Save timoschilling/c35b3eee7022e87c8027 to your computer and use it in GitHub Desktop.
Trailblazer::WithCurrentUser maps you the current_user in your Trb params hash, this is just a idea and not save for work!
class ApplicationController < ActionController::Base
include Trailblazer::Operation::Controller
include Trailblazer::WithCurrentUser
self.trb_with_current_user_param_key = :current_user
self.trb_with_current_user_method = :current_user
end
module Trailblazer::WithCurrentUser
[:form, :present, :collection, :run, :respond].each do |method|
define_method method do |*args, &block|
options = args.extract_options!
options[:params][trb_with_current_user_param_key] = send(trb_with_current_user_method)
args << options
super *args, &block
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment