Hello,
j'ai passé une application rails en 2.1 et mis a jour Attachment_fu, seulement j'ai un problème, impossible de definir les propriété qui n'ont pas de rapport avec attachment_fu, par exemple j'ai fait une gallerie photo, et j'ai ajouté title et description comme propriété, seulement impossible de les définir en même temps que l'upload, il sont a nils, je suis obliger de les définir aprés via monObject.title = "foo", Savez vous d'ou peut venir ce problème ?
voila le code en rapport :
Le formulaire:
Le model :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 <h1>New photo</h1> <%= error_messages_for :photo %> <% form_for(@photo, :html => {:multipart => true}) do |f| %> <p> <b>Filename</b><br /> <%= f.file_field :uploaded_data %> </p> <p> <b>Title</b><br /> <%= f.text_field :title %> </p> <p> <b>Description</b><br /> <%= f.text_field :description %> </p> <p> <%= f.submit "Create" %> </p> <% end %> <%= link_to 'Back', photos_path %>
et le controlleur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 class Photo < ActiveRecord::Base has_attachment :content_type => :image, :storage => :file_system, :max_size => 1024.kilobytes, :thumbnails => {:view => "800x800>", :thumb => "200x200>", :icon => "50x50>"} validates_as_attachment end
Impossible de trouver d'où ça vient
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 class PhotosController < ApplicationController caches_action :index, :show, :new cache_sweeper :photo_sweeper # GET /photos # GET /photos.xml def index @photos = Photo.find(:all, :conditions => "parent_id IS NULL", :order => "-id") respond_to do |format| format.html # index.html.erb format.xml { render :xml => @photos } end end # GET /photos/1 # GET /photos/1.xml def show @photo = Photo.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @photo } end end # GET /photos/new # GET /photos/new.xml def new @photo = Photo.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @photo } end end # POST /photos # POST /photos.xml def create @photo = Photo.new(params[:photo]) respond_to do |format| if @photo.save format.html { redirect_to(@photo) } format.xml { render :xml => @photo, :status => :created, :location => @photo } else format.html { render :action => "new" } format.xml { render :xml => @photo.errors, :status => :unprocessable_entity } end end end end
Voila j'espère que vous pourrez m'aider
Partager