我正在try 将图像合并到我的web应用程序中,在删除了很多功能后,我一直遇到这个错误.这取决于我的"创建"应用程序控制器,我不完全确定我应该从这里走到哪里.

2015-02-06T20:30:12.292187+00:00 app[web.1]:    (1.9ms)  ROLLBACK
2015-02-06T20:30:12.296299+00:00 app[web.1]: NameError (uninitialized constant Paperclip::Storage::S3::AWS):
2015-02-06T20:30:12.296301+00:00 app[web.1]:   app/controllers/articles_controller.rb:24:in `create'
2015-02-06T20:45:14.691084+00:00 app[web.1]: [paperclip] saving /articles/images/000/000/013/original/git.jpeg
2015-02-06T20:45:14.698744+00:00 app[web.1]: Completed 500 Internal Server Error in 584ms
2015-02-06T20:45:14.700871+00:00 heroku[router]: at=info method=POST path="/articles" host=preston.herokuapp.com request_id=d9d02257-3616-4686-bce5-3d912cd528c2 fwd="76.22.102.38" dyno=web.1 connect=1ms service=698ms status=500 bytes=1754

我是你的管制员.rb

class ArticlesController < ApplicationController
http_basic_authenticate_with name: "name", password: "password", except: [:index, :show]

    def index
        @articles = Article.all.order("created_at DESC")
    end

    def show
        @article = Article.find(params[:id])
    end

    def new
        @article = Article.new
    end 

    def edit
        @article = Article.find(params[:id])

    end

    def create
        @article = Article.new(article_params)

        if @article.save
          redirect_to @article
        else
            render 'new'
        end  
    end

    def update
        @article = Article.find(params[:id])

        if @article.update(article_params)
            redirect_to @article
        else
            render 'edit'
        end
    end

    def destroy
        @article = Article.find(params[:id])
        @article.destroy

        redirect_to articles_path
    end

    private

    def article_params
        params.require(:article).permit(:title, :text, :image)
    end
end

Gemfile

source 'https://rubygems.org'
ruby '2.0.0'

gem 'rails', '4.2.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'bootstrap-sass', '~> 3.3.3' 
gem 'autoprefixer-rails'
gem 'paperclip', '~> 4.2.1'
gem 'aws-sdk', '~> 2.0.22'

group :development, :test do
 gem 'byebug'
 gem 'web-console', '~> 2.0'
 gem 'spring'
 gem 'sqlite3'
end

group :production do
    gem 'pg'
    gem 'rails_12factor'
end

group :doc do
    gem 'sdoc', '~> 0.4.0', require: false
end

推荐答案

修改Gemfile的aws sdk以安装2.0之前的版本:

gem 'aws-sdk', '< 2.0'

新版本的aws sdk(2.0+)引入了这个问题.你可以在这里阅读更多:http://ruby.awsblog.com/post/TxFKSK2QJE6RPZ/Upcoming-Stable-Release-of-AWS-SDK-for-Ruby-Version-2

Ruby-on-rails相关问答推荐

如何在测试期间为 Rails 应用程序启用 Rails.cache 会话对象

在bash中匹配带有空格字符的字符串

如何从设计中删除/禁用注册

有没有办法在模型而不是视图中使用复数()?

如何在where子句中组合两个条件?

Rails 服务对象与 lib 类

带有查询字符串参数的 Rails 动作缓存

可以在 Rails/ActiveRecord 中使用 NULL 指定唯一索引吗?

Rails - 如何在 f.submit 上放置确认弹出窗口?

Rails 5:无法从参数中检索哈希值

如何在 Ruby 中创建一个新的 Date 实例

如何在特定时区(最好是我的应用程序的默认时区,而不是 UTC)中创建新的 DateTime 对象?

rails 4 before_validation on: :create 或 on: :save

Rails 范围为 IS NOT NULL 并且不为空/空白?

如何打印出范围之间的随机数?

# 轨道中的 TODO

为什么不对 Rspec + Selenium 使用共享的 ActiveRecord 连接?

如何在 Rails 4 中测试控制器关注点

Rails:为什么 with_exclusive_scope 受保护?关于如何使用它的任何好的做法?

如何删除删除选项表单 activeAdmin?