abraham icon indicating copy to clipboard operation
abraham copied to clipboard

Use another id than current_user's one

Open thomascailhol opened this issue 5 years ago • 5 comments

Hi there,

Thanks for the great job with Abraham. I was wondering if there was any possibility to pass in some other model id to a tour? Not just the user's one via current_user?

Thanks,

Thomas

thomascailhol avatar Oct 21 '20 07:10 thomascailhol

There are three places where we use current_user.id ... not quite sure yet how we'd make that configurable, but open to suggestions!

jabbett avatar Apr 15 '21 19:04 jabbett

Out of interest, why would you want to do this @thomascailhol ?

scarroll32 avatar Aug 01 '21 07:08 scarroll32

@jabbett Not sure if there is interest in moving this issue forward, but a potential way to refactor the code to make it work without current_user.id is to define an overridable function that is used in place of current_user. For example, we could do something like

def trackable_id
  current_user.id
end

This above defaults to using the current_user as the way to identify who the tours should relate to, but can easily then be overridden by someone else. It may also help remove the "implicit dependency" on how Devise does things. Haven't really thought it in it's entirety, but something like this could work (and may also help folks how are confused by having to have a current_user function (e.g. https://github.com/actmd/abraham/issues/61). Just my 2 cents =)

prschmid avatar Sep 15 '21 11:09 prschmid

@prschmid Thanks — I like it!

And it seems that it would be backwards-compatible for (I assume) most current Abraham users who have relied on the standard Devise setup.

jabbett avatar Oct 07 '21 13:10 jabbett

@prschmid I'm having the darnedest time figuring out where that overridable function should be defined such that it can be used within AbrahamHelper and AbrahamHistoriesController. Any advice?

jabbett avatar Feb 17 '22 17:02 jabbett