Method: Scrivito::Configuration.find_user

Defined in:
app/cms/scrivito/configuration.rb

.find_user(&find_user_proc) {|user_id| ... } ⇒ Object

Note:

This configuration key is optional. If it is not configured the in-place UI would behave normally, but would not be able to find any users.

Configures how to find users for the in-place UI.

Examples:

Return a “dummy” User

Scrivito.configure do |config|
  config.find_user do |user_id|
    Scrivito::User.define(user_id)
  end
end

Find the user with a custom user model and convert it to a User

Scrivito.configure do |config|
  config.find_user do |user_id|
    my_user = MyUserModel.find(user_id)
    if my_user
      my_user.to_scrivito_user
    end
  end
end

Parameters:

  • find_user_proc (Proc)

    proc for finding a user by the user id

Yield Parameters:

  • user_id (String)

    id of the user

Yield Returns:

  • (Scrivito::User)

    if the user with the given user id was found

  • (NilClass)

    if the user with the given user id was not found

Raises:



85
86
87
# File 'app/cms/scrivito/configuration.rb', line 85

def self.find_user(&find_user_proc)
  self.find_user_proc = find_user_proc
end