我一直在关注CarrierWave的Ryan Bates的Railscasts教程,你可以找到here
一切正常,除了当我去查看我的个人资料时,它给了我这个错误:
undefined local variable or method `user'
我不知道为什么它告诉我这个,因为我使用Devise进行身份验证,这就是我的模型的名称。
以下是一些可能有用的文件:
https://gist.github.com/amarh21/7439421
我正在使用Rails 4.0.1和ruby 2.0.0
答案 0 :(得分:0)
您应该共享您的控制器。无论如何,我认为问题不在于Carrierwave。看起来问题是你没有正确设置变量。在你的控制器中你应该有一些东西:
def profile
user = User.find(params[:id])
end
您必须使用实例变量,实例变量的名称以@开头,其范围仅限于自我引用的任何对象。因此,请在控制器中将user
替换为@user
并查看:
def profile
@user = User.find(params[:id])
end
<%= image_tag @user.profile_image_url %>