Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError (undefined method `right' for an instance of String) #3491

Open
2 of 5 tasks
AhmedAliIbrahim opened this issue Dec 4, 2024 · 3 comments
Open
2 of 5 tasks
Labels
Waiting on Reproduction Pending reproduction repository or detailed reproduction steps to proceed with issue resolution.

Comments

@AhmedAliIbrahim
Copy link

AhmedAliIbrahim commented Dec 4, 2024

Context

TypeError (exception class/object expected)
Caused by: NoMethodError (undefined method `right' for an instance of String)

full log

Processing by Avo::SearchController#show as */*
Parameters: {"force_locale"=>"en", "q"=>"Maple", "global"=>"false", "resource_name"=>"products"}
Role Load (9.6ms)  SELECT "roles".* FROM "roles" INNER JOIN "users_roles" ON "roles"."id" = "users_roles"."role_id" WHERE "users_roles"."user_id" = $1  [["user_id", 1]]
Completed 500 Internal Server Error in 100ms (ActiveRecord: 77.5ms (1 query, 0 cached) | GC: 5.1ms)
 TypeError (exception class/object expected)
 Caused by: NoMethodError (undefined method `right' for an instance of String)
 Information for: TypeError (exception class/object expected):
self.search = {
        results_count: 5,
        query: lambda {
                 query.ransack(
                   name_cont: params[:q],
                   name_start: params[:q],
                   slug_cont: params[:q],
                   category_name_cont: params[:q],
                   m: 'or'
                 ).result(distinct: true)
               },
        item: lambda {
                {
                  title: record&.name&.to_s,
                  description: record&.status,
                  image_url: (main_app.url_for(record.images.first) if record.images.attached?),
                  image_format: :rounded
                }
              },
        help: -> { 'Search by product' }
      }

System configuration

Avo version: 3.15.1

Rails version: 8.0.0

Ruby version: 3.3.6

License type

  • Community
  • Pro
  • Advanced

Are you using Avo monkey patches, overriding views or view components?

  • Yes. If so, please post code samples.
  • No

Screenshots or screen recordings

Image

@Paul-Bob
Copy link
Contributor

Paul-Bob commented Dec 5, 2024

Hi @AhmedAliIbrahim I wasn't able to reproduce this error, could you please include a minimal reproduction repository?

Here is a quick guide on how to do it in no time!

@Paul-Bob Paul-Bob added the Waiting on Reproduction Pending reproduction repository or detailed reproduction steps to proceed with issue resolution. label Dec 5, 2024
@m7madmagdy
Copy link

Hi, @Paul-Bob, this error occurs in the resource because of this line.

self.index query { query.i18n }

@Paul-Bob
Copy link
Contributor

Paul-Bob commented Dec 5, 2024

For me, trying to apply i18n to a query inside self.index_query throws another error:

>> query.i18n
NoMethodError: undefined method `i18n' for class User
	from /home/bob/Projects/gems/avo/spec/dummy/app/avo/resources/user.rb:21:in `block in <class:User>'

Could you please provide a reproduction repository so that we are on the same page?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Waiting on Reproduction Pending reproduction repository or detailed reproduction steps to proceed with issue resolution.
Projects
Status: No status
Development

No branches or pull requests

3 participants