回形针是否需要所有 4 列(_file_name、_content_type 等)? [英] Does paperclip require all 4 columns (_file_name, _content_type,etc)?

查看:36
本文介绍了回形针是否需要所有 4 列(_file_name、_content_type 等)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 Paperclip 是否确实需要数据库中的所有四列:

I am wondering if Paperclip does require all four columns in database as:

  add_column :users, :avatar_file_name,    :string
  add_column :users, :avatar_content_type, :string
  add_column :users, :avatar_file_size,    :integer
  add_column :users, :avatar_updated_at,   :datetime

我可以只添加 avatar_file_name 吗?而不添加其他 3 列?

Can I just add the avatar_file_name? And not add the other 3 columns?

这是因为我不会使用回形针而不是 filecolumn gem.它仅使用 1 列,因此我不想填写回形针支持的所有列.

It is because I wont to use paperclip instead of the filecolumn gem. And it uses only 1 column therefor I don´t want fill out all columns that paperclip support.

推荐答案

我很确定你可以只添加一列 + 3 attr_accessor 扮演一个虚拟角色.

I'm pretty sure you could just add one column + 3 attr_accessor playing a dummy role.

但这看起来很尴尬,我不建议这样做.

But this looks awkward and I wouldn't advise to do so.

这篇关于回形针是否需要所有 4 列(_file_name、_content_type 等)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆