Sha256: f8173fa971941a632134d69bffe742fa59a59196cef31a23916544d1b8b4d724

Contents?: true

Size: 865 Bytes

Versions: 22

Compression:

Stored size: 865 Bytes

Contents

# tutorial (user resource): https://youtu.be/WgNK-oINFww?t=599
class UserResource < Avo::BaseResource
  # https://docs.avohq.io/2.0/resources.html#devise-password-optional
  # you need to fill in the password when creating a new user,
  # but when editing a user you can leave the password field empty
  self.devise_password_optional = true

  # tutorial (better search experience): https://youtu.be/WgNK-oINFww?t=649
  self.title = :email
  self.includes = []

  self.search_query = ->(params:) do
    scope
      .ransack(id_eq: params[:q], name_cont: params[:q], email_cont: params[:q], m: "or")
      .result(distinct: false)
  end

  field :id, as: :id
  field :email, as: :gravatar, link_to_resource: true, as_avatar: true
  field :name, as: :text
  field :email, as: :text, as_description: true
  field :password, as: :text
  field :posts, as: :has_many
end

Version data entries

22 entries across 12 versions & 1 rubygems

Version Path
rails_app_generator-0.3.6 after_templates/application/klueless/app/avo/resources/user_resource.rb
rails_app_generator-0.3.6 after_templates/addons/avo/app/avo/resources/user_resource.rb
rails_app_generator-0.3.5 after_templates/addons/avo/app/avo/resources/user_resource.rb
rails_app_generator-0.3.5 after_templates/application/klueless/app/avo/resources/user_resource.rb
rails_app_generator-0.3.4 after_templates/application/klueless/app/avo/resources/user_resource.rb
rails_app_generator-0.3.4 after_templates/addons/avo/app/avo/resources/user_resource.rb
rails_app_generator-0.3.3 after_templates/application/klueless/app/avo/resources/user_resource.rb
rails_app_generator-0.3.3 after_templates/addons/avo/app/avo/resources/user_resource.rb
rails_app_generator-0.3.2 after_templates/application/klueless/app/avo/resources/user_resource.rb
rails_app_generator-0.3.2 after_templates/addons/avo/app/avo/resources/user_resource.rb
rails_app_generator-0.3.1 after_templates/application/klueless/app/avo/resources/user_resource.rb
rails_app_generator-0.3.1 after_templates/addons/avo/app/avo/resources/user_resource.rb
rails_app_generator-0.3.0 after_templates/application/klueless/app/avo/resources/user_resource.rb
rails_app_generator-0.3.0 after_templates/addons/avo/app/avo/resources/user_resource.rb
rails_app_generator-0.2.43 after_templates/application/klueless/app/avo/resources/user_resource.rb
rails_app_generator-0.2.43 after_templates/addons/avo/app/avo/resources/user_resource.rb
rails_app_generator-0.2.42 after_templates/addons/avo/app/avo/resources/user_resource.rb
rails_app_generator-0.2.42 after_templates/application/klueless/app/avo/resources/user_resource.rb
rails_app_generator-0.2.41 after_templates/application/klueless/app/avo/resources/user_resource.rb
rails_app_generator-0.2.41 after_templates/addons/avo/app/avo/resources/user_resource.rb