Я следую инструкции здесь: http://webtempest.com/how-to-allow-image-uploads-in-rails-on-heroku/ И я получаю сообщение об ошибке всякий раз, когда пытаюсь запустить сервер rails - ниже я добавил файлы, которые были изменены с соответствующим кодом.Я не понимаю, однако, откуда исходит ошибка:
ошибка
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
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 (на данный момент пусто, потому что я даже не могу перейти к следующему шагу в руководстве, поскольку рельсы сталкиваются с ошибкой)
access_key_id:
secret_access_key:
bucket:
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