ruby-on-rails – 使用Paperclip上传图片时出现“未知属性:头像
发布时间:2020-12-16 21:21:01 所属栏目:百科 来源:网络整理
导读:我运行了这个迁移: rails generate paperclip user avatar 它创建了这个迁移文件: class AddAttachmentAvatarToUsers ActiveRecord::Migration def self.up change_table :users do |t| t.attachment :avatar end end def self.down drop_attached_file :u
我运行了这个迁移:
rails generate paperclip user avatar 它创建了这个迁移文件: class AddAttachmentAvatarToUsers < ActiveRecord::Migration def self.up change_table :users do |t| t.attachment :avatar end end def self.down drop_attached_file :users,:avatar end end 我将其添加到我的编辑用户注册视图中: <div class="form-group"> <%= f.label :avatar %> <br> <%= f.file_field :avatar,:autofocus => true,class: 'form-control' %> </div> 当我尝试在编辑用户注册中上传头像时,我收到此错误: Devise :: RegistrationsController#update中的ActiveRecord :: UnknownAttributeError EDITS 我补充道 def user_params params.require(:user).permit(:avatar) end 到我的用户模型,现在我没有得到错误,但现在配置文件图片只是作为链接打印出来.我想我能找到答案. 解决方法
您确定通过控制器许可证允许:avatar属性吗?
另外,您是否在模型中提到了以下代码行? has_attached_file :avatar (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- xcode – 安装声称已成功,但无法在设备上找到应用程序
- flutter – 如何获得ScrollController的完整大小
- ajax – 使用JsonRest Store(dojo)自定义http标头
- 使用Feed服务添加手机聚合平台教程
- iphone – 在Xcode 4.3中添加UIViewController子类
- postgresql数据库基础
- [OpenWrt] Flash 由4M改8M(或者16M), openwrt源码的修改
- ruby-on-rails – 如何关闭Rails SQL日志记录测试?
- 值得尝试的10款出色NoSQL数据库
- c# – 检测Windows重新启动是否是由Windows更新引起的