actmd/abraham

Use another id than current_user's one

thomascailhol opened this issue · 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

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

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

@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. #61). Just my 2 cents =)

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

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