actmd / abraham

Trackable application tours for Rails with i18n support
MIT License
124 stars 45 forks source link

Use another id than current_user's one #37

Open thomascailhol opened 4 years ago

thomascailhol commented 4 years ago

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

jabbett commented 3 years ago

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

scarroll32 commented 3 years ago

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

prschmid commented 3 years ago

@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 =)

jabbett commented 3 years ago

@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 commented 2 years ago

@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?