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
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

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

Post

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.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Probably a digression (1 comment)
Probably a digression
Trilarion‭ wrote almost 3 years ago

Line "background = "##{Digest::MD5.hexdigest(user.username)[0...6]}FF"" got removed in the latest commit to that file: https://github.com/codidact/qpixel/commit/cb7380a5ee6a933170d94dabc4b52dcc64d10aee#diff-2695b54932747a21a39444e7981463d365d96a14b78e9510518eaee6ce4f90d8

I can probably fix it myself.