Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 图像上载内部服务器错误Ruby_Ruby On Rails_Carrierwave_Internal Server Error - Fatal编程技术网

Ruby on rails 图像上载内部服务器错误Ruby

Ruby on rails 图像上载内部服务器错误Ruby,ruby-on-rails,carrierwave,internal-server-error,Ruby On Rails,Carrierwave,Internal Server Error,当我试图在我正在使用的Ruby应用程序中上载图像时,我遇到了一个内部服务器错误。我知道问题本身是什么,但我不完全确定如何解决它。到目前为止,该应用程序的工作原理如下: 用户访问页面,允许上传图片,上传后进行图片处理。因此,当用户访问页面时,我将创建一个新的库实例(库包含一个或多个图片)。问题出现在我试图创建以下内容的gallery controller中: def index @gallery = Gallery.create @picture = @gallery.pi

当我试图在我正在使用的Ruby应用程序中上载图像时,我遇到了一个内部服务器错误。我知道问题本身是什么,但我不完全确定如何解决它。到目前为止,该应用程序的工作原理如下:

用户访问页面,允许上传图片,上传后进行图片处理。因此,当用户访问页面时,我将创建一个新的库实例(库包含一个或多个图片)。问题出现在我试图创建以下内容的gallery controller中:

    def index
    @gallery = Gallery.create
    @picture = @gallery.pictures.build

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @galleries }
    end
  end
Annddd运行“localhost:3000/gallers/”时出现的错误

在148ms内完成500个内部服务器错误
ActionView::Template::Error(针对#的未定义方法“gallery_pictures_path”):
三:
4: 
5: 
6:{:multipart=>true,:id=>fileupload}do | f |%>
7: 
8:     
9:         
app/views/galleries/index.html.erb:6:in`_app_views_galleries_index_html_erb__27954778836341012416_2164674980'
app/controllers/gallers\u controller.rb:8:in'index'
项目本身位于GitHub上,如下所示:

问题在于我对Gallery.create的理解以及如何创建新实例(我知道孤立实例的风险,但我将在修复此上载问题后实施过期日期),或者我对图片和图库如何连接的理解不允许@Gallery.Pictures为无效路径

谢谢你的帮助

在routes.rb中尝试此操作

resources :galleries, :shallow => true do
    resources :pictures
end

哇!真不敢相信我竟然忘了修路线。谢谢你抓住了那个白痴。
resources :galleries, :shallow => true do
    resources :pictures
end