제품을 만들 때 Paperclip gem, paperclip-dropbox gem, figaro gem 및 보관 용을 사용하여 이미지를 업로드하고 저장합니다. 개발 중에는 이미지 파일이 데이터베이스에 잘 업로드되어 표시되지만 생산시에는 이미지가 Dropbox로 이동한다고 가정 할 때 양식이 통과하지 않고 볼 때 Dropbox 인증 오류가 발생합니다 내 Heroku 로그. Dropbox 보안 키가 모두 정확한지 확인했습니다. 나는 관련된 모든 질문을 살펴 봤는데 아무 것도 찾을 수 없다.레일 4 - 종이 클립 - 보관 용구 문제
: 다음# POST /products
# POST /products.json
def create
@product = Product.new(product_params)
@product.user = current_user
respond_to do |format|
if @product.save
format.html {
redirect_to @product,
notice: 'Product was successfully created.'
}
format.json {
render json: @product,
status: :created,
location: @product
}
else
format.html { render :new }
format.json {
render json: @product.errors,
status: :unprocessable_entity
}
end
end
end
이 products_create의 끝에 PARAMS입니다 : 여기
DropboxAuthError (User is not authenticated.): 2014-07-12T16:04:12.514637+00:00 app[web.1]: app/controllers/products_controller.rb:31:in `block in create' 2014-07-12T16:04:12.514638+00:00 app[web.1]: app/controllers/products_controller.rb:30:in `create' 2014-07-12T16:04:12.514640+00:00 app[web.1]: 2014-07-12T16:04:12.514642+00:00 app[web.1]: 2014-07-12T16:04:12.512474+00:00 app[web.1]: Completed 500 Internal Server Error in 2361ms
내 products_controller의 # 만들기 작업입니다 : 여기 는 Heroku가에서 오류가
private
def set_product
@product = Product.find(params[:id])
end
def product_params
params.require(:product).permit(:description, :name, :permalink, :price, :file, :user_id)
end
여기 내 제품 모델 :
class Product < ActiveRecord::Base
if Rails.env.development?
has_attached_file :file
else
has_attached_file :file,
:storage => :dropbox,
:dropbox_credentials => Rails.root.join("config/dropbox.yml"),
:path => ":style/:id_:filename"
end
belongs_to :user
has_many :sales
validates_numericality_of :price,
greater_than: 49,
message: "must be at least 50 cents"
validates_attachment_content_type :file, :content_type => %w(image/jpeg image/jpg image/png)
end
그리고 마지막으로 여기에 새로운 제품을 만드는 형태입니다 :
<%= form_for(@product,:html => { :multipart => true }) do |f| %>
<% if @product.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@product.errors.count, "error") %> prohibited this product from being saved:</h2>
<ul>
<% @product.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br>
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :permalink %><br>
<%= f.text_field :permalink %>
</div>
<div class="field">
<%= f.label :description %><br>
<%= f.text_area :description %>
</div>
<div class="field">
<%= f.label :price %><br>
<%= f.number_field :price %>
</div>
<div class="field">
<%= f.label :user_id %><br>
<%= f.text_field :user_id %>
</div>
<div class="field">
<%= f.label :file %><br />
<%= f.file_field :file %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
이