I've installed the filepicker-rails
gem and I am able to upload files to the filepicker.io
server. When I try to display the image for different users profile, I get the error:
undefined method 'avatar_url' for nil:NilClass
Under my users directory, in the show.html.erb file I have:
<%= filepicker_image_tag @user.avatar_url, w: 160, h: 160, fit: 'clip' %>
I have the following under my User.rb file:
def avatar_url(user)
user.avatar_url
end
Any ideas why this doesn't work?
Basically you'll need a column in your DB called avatar_url
. Write a migration that will give you a avatar_url
column as just a regular string column. Since you're using Rails, ActiveRecord will provide the avatar_url
method for you.
Edit: In your controller you're likely not looking up your user correctly which is resulting in a method call on a NilClass in your view.