[英]Heroku + Devise + Paperclip + Amazon S3 Error
I'm following the guide here: http://webtempest.com/how-to-allow-image-uploads-in-rails-on-heroku/ And I am getting an error whenever I attempt to run rails server - below I've added the files that were changed with their respective code. 我在这里关注指南: http : //webtempest.com/how-to-allow-image-uploads-in-rails-on-heroku/我每次尝试运行rails服务器时都会收到错误 - 下面我已经添加了使用各自代码更改的文件。 I don't understand however where the error is coming from: 但我不明白错误来自哪里:
error 错误
sabiola@ubuntu:~/delta_bak$ rails server
=> Booting WEBrick
=> Rails 3.1.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/sabiola/delta_bak/app/models/user.rb:17: uninitialized constant User::RAILS_ROOT (NameError)
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.1.1/lib/active_support/inflector/methods.rb:113:in `constantize'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.1.1/lib/active_support/inflector/methods.rb:112:in `each'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.1.1/lib/active_support/inflector/methods.rb:112:in `constantize'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/devise-1.4.9/lib/devise.rb:259:in `get'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/devise-1.4.9/lib/devise/mapping.rb:103:in `to'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/devise-1.4.9/lib/devise/mapping.rb:98:in `modules'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/devise-1.4.9/lib/devise/mapping.rb:115:in `routes'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/devise-1.4.9/lib/devise/mapping.rb:84:in `initialize'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/devise-1.4.9/lib/devise.rb:289:in `new'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/devise-1.4.9/lib/devise.rb:289:in `add_mapping'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/devise-1.4.9/lib/devise/rails/routes.rb:190:in `devise_for'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/devise-1.4.9/lib/devise/rails/routes.rb:189:in `each'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/devise-1.4.9/lib/devise/rails/routes.rb:189:in `devise_for'
from /home/sabiola/delta_bak/config/routes.rb:4
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:258:in `instance_exec'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:258:in `eval_block'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:235:in `draw'
from /home/sabiola/delta_bak/config/routes.rb:1
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:29:in `load_paths'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:29:in `each'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:29:in `load_paths'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:13:in `reload!'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/application/routes_reloader.rb:7:in `initialize'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:32:in `call'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:32:in `execute_if_updated'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/application/finisher.rb:63
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/application/finisher.rb:64:in `call'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/application/finisher.rb:64
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `run_initializers'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `send'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/sabiola/delta_bak/config/environment.rb:5
from /home/sabiola/delta_bak/config.ru:4
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/rack-1.3.5/lib/rack/builder.rb:51:in `instance_eval'
from /home/sabiola/.rvm/gems/ruby-1.8.7-p352/gems/rack-1.3.5/lib/rack/builder.rb:51:in `initialize'
from /home/sabiola/delta_bak/config.ru:1:in `new'
from /home/sabiola/delta_bak/config.ru:1
user.rb user.rb
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me,
:firstname, :middlename, :lastname, :discipline, :peeruser,
:concept, :course, :comment, :academic, :photo
has_attached_file :photo, :styles => {
:thumb => "100x100",
:medium => "200x200",
:large => "600x400"
},
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":attachment/:id/:style.:extension",
:bucket => 'yourbucket'
end
s3.yml (blank at the moment because I can't even get to the next step on the guide since rails is running into an error) s3.yml (目前空白,因为我甚至无法进入指南的下一步,因为rails遇到错误)
access_key_id:
secret_access_key:
bucket:
add_photo_to_users.rb add_photo_to_users.rb
class AddPhotoToUsers < ActiveRecord::Migration
def self.up
add_column :users, :photo_file_name, :string
add_column :users, :photo_content_type, :string
add_column :users, :photo_file_size, :integer
add_column :users, :photo_updated_at, :datetime
end
def self.down
remove_column :users, :photo_file_name
remove_column :users, :photo_content_type
remove_column :users, :photo_file_size
remove_column :users, :photo_updated_at
end
end
The constant RAILS_ROOT
is deprecated and is not available in 3.1 (IMHO) 常量RAILS_ROOT
已弃用,在3.1(恕我直言)中不可用
Try using : :s3_credentials => "#{Rails.root}/config/s3.yml"
尝试使用:: :s3_credentials => "#{Rails.root}/config/s3.yml"
Instead of :s3_credentials => "#{RAILS_ROOT}/config/s3.yml"
而不是:s3_credentials => "#{RAILS_ROOT}/config/s3.yml"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.