Skip to content

Using a custom current_user_getter

cgooley edited this page Oct 16, 2014 · 2 revisions

If you're not using Devise/Warden for authentication, you'll need to provide a method for Preact to access the identity information about the current user. Ideally, this will be a method or variable in your application_controller which returns the User model.

Option 1

If you already have a method like get_the_logged_in_user which returns a model, then this is very easy. Simply uncomment the following line in preact.yml and replace with the name of the method or instance variable. Remember to prefix an instance variable with the @ symbol.

current_user_getter: "get_the_logged_in_user"

Then you will also want to add a to_preact method to the model returned by that method. See the quickstart for those instructions.

Option 2

If you don't already have a method to return the current user, simply create one in your application_controller and then jump up to Option 1 above.

Easy

Clone this wiki locally