【发布时间】:2014-01-31 03:38:02
【问题描述】:
我正在尝试使用 Paperclip 和 S3 将头像上传到 Devise 模型
index.html.haml
= form_for(@user) do |f|
- if @user.errors.any?
#error_explanation
%h2
= pluralize(@user.errors.count, "error")
prohibited this friend from being saved:
%ul
- @user.errors.full_messages.each do |msg|
%li= msg
.field
= f.label :avatar
%br
= f.file_field :avatar
%br
.actions
= f.submit 'Upload avatar'
routes.rb
resources :users
paperclip.rb(初始化器,这是全部内容)
Paperclip::Attachment.default_options[:storage] = :s3
Paperclip::Attachment.default_options[:s3_protocol] = 'http'
Paperclip::Attachment.default_options[:s3_credentials] =
{ :bucket => 'secret',
:access_key_id => 'secret',
:secret_access_key => 'secret' }
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'
Paperclip::Attachment.default_options[:s3_host_name] = 's3-us-west-2.amazonaws.com'
index_controller.rb
def index
@user = User.new
end
production.rb & development.rb
# Nothing to do with paperclip
所以我的问题是:当我上传图片时,我得到一个 路由错误:未初始化的常量 UsersController
我对 Rails 还是很陌生。 我能做些什么?或者有人有例子吗?
【问题讨论】:
标签: ruby-on-rails devise amazon-s3 ruby-on-rails-4 paperclip