ROR- Step by step multiple images using Paperclip

荒凉一梦 提交于 2019-12-05 01:34:22

问题


I have used the "tutorial" on here but for some reason it didn't work.

Can anyone give me a step-by-step guide for setting up a multiple image form (upload) with other form elements ...

Also another tutorial (a good one) may be provided.

I only want to use the paperclip plugin.

@Gordon Isnor: I have uploaded my current (noob) project with some functionality (login, register) but it's not even fine tuned a little. I'm only trying to get the multiple images working, all code of the "multiple" images is deleted in this source. So it's clean and running. (don't notice the current login for now ;-)) Ps. Using the default's nifty_scaffold and etc... :)

For stackoverflow's eyes only: Rapidshare link (- 100 kb.


回答1:


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.



来源:https://stackoverflow.com/questions/2308103/ror-step-by-step-multiple-images-using-paperclip

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