나는 Heroku에서 잘 돌아가는 앱을 가지고 있으며, 앱을 Carrierwave와 Amazon S3 서비스에 연결하려고 시도하고 있습니다. 나는 모든 것을 위해 작동하는 config 파일을 가지고 있다고 생각했지만 그림 인스턴스를 만들 때 문제가 발생했습니다. Postgres 및 특정 형식 지정과 관련이 있다고 생각하지만 여기에는 주요 문제가 있습니다.Postgres + Heroku Ruby Creation
TypeError (can't convert nil into String):
은 (특히 작성 메소드에 대한) 데이터베이스에 대한 POST와 같은 것으로 보입니다. 뿐만 아니라 POST의 시작을 여기
app/controllers/pictures_controller.rb:62:in `create'
TypeError (can't convert nil into String):
POST xxxxxxxx.herokuapp.com/684-536-025/pictures dyno=web.1 queue=0 wait=0ms service=510ms status=500 bytes=643
입니다 :
#<Picture id: nil, description: nil, image: nil, gallery_id: 15, gallery_url_id: "a432b35_21cc", original_filename: "Sunflower.gif", order_number: nil, created_at: nil, updated_at: nil>
을 나는 문제가 여기에 필드가있을 때 포스트 그레스는 POST를 시작 허용하지 않는 것을 가정하고 다음과 같이 오류가 보인다 그게 없어요. 이상하게도 충분히 sqlite는 이것으로 문제없이 Postgres를 추측하고 불행하게도 Postgres를 프로덕션에 사용합니다. 나는이 문제를 정말로 좁히기 위해 Postgres에 관해 충분히 알지 못한다. 그래서 나는 도움이나 조언을 얻을 수 있는지 여기에서 물을 것이라고 생각했다.
감사합니다.
편집 : 여기에 추가 도움
라인 (62)이 코드에 표시되어
def create
# Creates a picture class instance based on the json objects being passed in from
# Carrierwave
p_attr = params[:picture]
p_attr[:image] = params[:picture][:image].first if params[:picture][:image].class == Array
# Gets the gallery vai the uuid gallery url
@gallery = Gallery.where(:url_id => params[:url_id]).first
# Builds the picture based on the attributes passed in above from the json
@picture = @gallery.pictures.build(p_attr)
# Assigns the gallery_url_id attribute
@picture.gallery_url_id = @gallery.url_id
puts @picture.inspect
# Handle the picture save according to success or not
LINE 62 -> if @picture.save
respond_to do |format|
format.html {
# Calls the method in the model to format the json repsonse
render :json => [@picture.to_jq_upload].to_json,
:content_type => 'text/html',
:layout => false
}
format.json {
render :json => [@picture.to_jq_upload].to_json
}
end
else
render :json => [{:error => "custom_failure"}], :status => 304
end
끝의 만드는 방법입니다.
편집 2 : 여기에 요청에 따라 모델은 ...
class Picture < ActiveRecord::Base
# The attributes accesible via an @picture
attr_accessible :gallery_id, :description, :image, :gallery_url_id, :original_filename, :order_number
belongs_to :gallery
# Attatches the carrierwave uploader to the picture class
mount_uploader :image, ImageUploader
# Referenced when each picture is created, the json is formatted as the following form
def to_jq_upload
{
"name" => read_attribute(:image),
"size" => image.size,
"url" => image.url,
"thumbnail_url" => image.thumb.url,
"delete_url" => id,
"picture_id" => id,
"delete_type" => "DELETE",
"url_id" => read_attribute(:gallery_url_id),
"original_filename" => read_attribute(:original_filename),
"order_number" => ""
}
end
end
사진 컨트롤러의 라인 62는 정확히 무엇이며 유형 오류를 일으키지 않는 필드는 무엇입니까? app/controllers/pictures_controller.rb : 62 :'create ' – bento
나는 create 메소드를 사용하여 게시물을 업데이트 할 것이므로 도움이 될 것입니다. 그래도 찾는 속성을 처리해야 할 수도 있습니다 ... – user1470511
사진 모델을 볼 수 있습니까? – Andrei