In my application.html.erb, I have a navigation bar that stores the user
avatar. He or she should be able to return to the main index or traverse
through the different controllers without issue. I seem to be getting a
"Cannot find avatar for type ActiveRecord::Relation"
I think error message is obvious
you got that error because @user was nil
if you're using devise, you can try this instead
"current_user.avatar.url(:thumb)"
I think error message is obvious
you got that error because @user was nil
if you're using devise, you can try this instead
"current_user.avatar.url(:thumb)"
--
Mou Dareka no, tame janakutte
Jibun no Tame ni Warette Iru
( Aqua Timez - Alones )
I'm getting this error in my logs file. The current_user is signed in
btw.
User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ?
ORDER BY "users"."id" ASC LIMIT 1 [["id", 3]]
Completed 500 Internal Server Error in 2302ms (ActiveRecord: 2.0ms)
NameError - undefined local variable or method `avatar' for
#<#<Class:0x58867e0>:0x5885d78>:
Is that the same error (undefined method `avatar' for nil:NilClass) or
a new one? If a new one then show us the full error message and the
line of code it relates to. If the same error then, as the previous
poster said, it is because @user is nil.
Also what is the code
unless: avatar.nil?
supposed to be doing? I see no code setting up a variable avatar.