ROR- Step by step multiple images using Paperclip

馋奶兔 提交于 2019-12-03 16:38:05

Do you have examples of code? It would be easier to help if there was something to look at, or a more detailed description of how it’s not working.

Ok --

Some points to help you get started:

1 - in your Progress model you are accepting nested attributes for a model that does not exist: you need a ProgressImage model with a Paperclip attachment:

class ProgressImage < ActiveRecord::Base
  belongs_to :progress
  has_attached_file :photo
end

2 - Your progress form is not multipart, it will needs to be:

<% form_for @progress, :html => { :multipart => true } do |f| %>

3 - Your progress form needs nested attribute file fields, there are various articles about how to do this:

http://weblog.rubyonrails.org/2009/1/26/nested-model-forms

4- There’s also a plugin that I have found useful for nested attribute forms, called add_nested_fields: http://github.com/miletbaker/add_nested_fields

5 - You have a migration to add paperclip columns to the non-existent progress images table - you might as well change that migration to create the table, and include those paperclip-specific columns and then you need to run it using rake db:migrate.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!