Я пишу демо на практику жемчужины «carrierwave», и он работал все хорошо в ENV развития, но потерпел неудачу, когда я развернут Heroku.неинициализированной постоянная Статья :: PictureUploader (NameError)
Когда я: Heroku запустить Rails S, получите эту ошибку:
/app/app/models/article.rb:9:in `': uninitialized constant Article::PictureUploader (NameError)
Там в мои коды: приложение/модели/article.rb
class Article < ActiveRecord::Base
belongs_to :user
has_many :comments, dependent: :destroy
has_many :likes
validates :title, presence: true, length: {maximum: 50}
validates :content, length: {minimum: 10}
self.per_page = 10
attr_accessor :floor_number
mount_uploader :picture, PictureUploader
validate :picture_size
закачивающие/picture_uploader.rb
class PictureUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
process resize_to_limit: [600, 600]
storage :qiniu
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def extension_white_list
%w{jpg gif png jpeg}
end
end
db/schema.rb
ActiveRecord::Schema.define(version: 20150529021048) do
create_table "articles", force: :cascade do |t|
t.string "title"
t.text "content"
t.string "label"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "picture"
end
add_index "articles", ["user_id"], name: "index_articles_on_user_id"
create_table "comments", force: :cascade do |t|
t.text "content"
t.integer "article_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
end
add_index "comments", ["article_id"], name: "index_comments_on_article_id"
add_index "comments", ["user_id"], name: "index_comments_on_user_id"
create_table "likes", force: :cascade do |t|
t.integer "likes_num"
t.integer "article_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "likes", ["article_id"], name: "index_likes_on_article_id"
create_table "messages", force: :cascade do |t|
t.text "content"
t.integer "user_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "messages", ["user_id"], name: "index_messages_on_user_id"
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "name"
t.boolean "admin"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "users", ["email"], name: "index_users_on_email", unique: true
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
Ошибка:
yesijiedeMacBook-Pro:blog killernova$ heroku run rails c Running
rails c
attached to terminal... up, run.2077 /app/app/models/article.rb:9:in<class:Article>': uninitialized constant Article::PictureUploader (NameError) from /app/app/models/article.rb:1:in
' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:472:inblock (2 levels) in eager_load!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:471:in
each' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:471:inblock in eager_load!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:469:in
each' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:469:ineager_load!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:346:in
eager_load!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/application/finisher.rb:56:ineach' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/application/finisher.rb:56:in
block in ' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/initializable.rb:30:ininstance_exec' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/initializable.rb:30:in
run' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/initializable.rb:55:inblock in run_initializers' from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:150:in
block in tsort_each' from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:183:inblock (2 levels) in each_strongly_connected_component' from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:219:in
each_strongly_connected_component_from' from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:182:inblock in each_strongly_connected_component' from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in
each' from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:ineach_strongly_connected_component' from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:148:in
tsort_each' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/initializable.rb:54:inrun_initializers' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/application.rb:352:in
initialize!' from /app/config/environment.rb:5:in<top (required)>' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/application.rb:328:in
require_environment!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:142:inrequire_application_and_environment!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:67:in
console' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:inrun_command!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in
' from /app/bin/rails:4:inrequire' from /app/bin/rails:4:in
' yesijiedeMacBook-Pro:blog killernova$
: qiqiu еще одна жемчужина "carrierwave-qiniu".
Все в порядке в localhost: 3000, поэтому каждый хотел бы сказать мне, где я ошибаюсь? Благодаря!
GitHub: https://github.com/killernova/blog
пожалуйста, напишите ваш PictureUploader файл –
@Amit Шарма I'v добавил вышеуказанный файл, спасибо. – killernova
У вас есть 'require 'carrierwave/orm/activerecord'' в файле' config/environment.rb'? Если не пытайтесь добавить его и проверить. – Pavan