문제

I'm trying to render a User's Avatar on a Show Page.

Scenario: User creates Account and set's Avatar. Avatar is displayed correctly oh his Profile page(stretchy but its there). But on another Page is says

undefined method `avatar' for nil:NilClass

the code is

<%= image_tag @user.avatar.url(:avatar), class: "size48" %> 

Edit

In my Views folder the image get's rendered only on the USERS folder, on the other folders im getting this error.

UserModel -> http://pastebin.com/pdTTLgrw

도움이 되었습니까?

해결책

@user variable is nil. There should be @user = User.find(params[:id]) in the controller action of the page you're trying to load.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top