Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs

Dashboard
Notifications
Mark all as read
Q&A

How to fix NameError (undefined local variable or method `background' for #<#<Class) in avatar_helper.rb? Question

+0
−0

I'm setting up a QPixel instance. I just created a new category and I realized in the rails s output a NameError in avatar_helper.rb:

Started GET "/users/1/avatar/40.png" for 127.0.0.1 at 2022-01-12 22:37:01 +0100
Started GET "/assets/codidact.png" for 127.0.0.1 at 2022-01-12 22:37:01 +0100
Processing by UsersController#avatar as PNG
  Parameters: {"id"=>"1", "size"=>"40"}
  Host localhost:3000, community #1 (Dev Community)
  User Load (4.4ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
  CommunityUser Load (5.6ms)  SELECT  `community_users`.* FROM `community_users` WHERE `community_users`.`user_id` = 1 AND `community_users`.`community_id` = 1 LIMIT 1
  User 1 (aaa) signed in
  ....
NameError (undefined local variable or method `background' for #<#<Class:0x00007f2dad266998>:0x00007f2dacaeec38>):

app/helpers/users/avatar_helper.rb:28:in `block in user_auto_avatar'
config/initializers/namespaced_cache.rb:11:in `block (2 levels) in <class:NamespacedEnvCache>'
app/helpers/users/avatar_helper.rb:23:in `user_auto_avatar'
app/controllers/users_controller.rb:474:in `block (2 levels) in avatar'
app/controllers/users_controller.rb:471:in `avatar'
Processing by ErrorsController#error as PNG
  Parameters: {"id"=>"1", "size"=>"40"}
  Host localhost:3000, community #1 (Dev Community)
  User 1 (aaa) signed in
  ...
Completed 500 Internal Server Error in 214ms (Views: 126.5ms | ActiveRecord: 25.9ms)

I haven't set an avatar yet and the page output looks okay too (no error message visible, but also no avatar image).

Is it critical? Should I do something?


Tried to fix it and created a PR.

Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Probably a digression (1 comment)

1 answer

You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.

+0
−0

It was a minor regression. Fixed in https://github.com/codidact/qpixel/commit/993562804a2843d1e96764ffe6d955f9f333389d

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!

Like what we're doing? Support us! Donate