0

Hi I'm trying to build a little gallery for myself and tried this link for multiple uploads for a album: http://www.mfischer.com/wordpress/2009/02/02/multiple-image-upload-and-crop-with-rails/

So far I'm running into following error when I visit localhost:3000/albums/new :

ArgumentError in AlbumsController#index
Unknown key(s): attributes, discard_if

Since I am not sure whether the attachment_fu-Plugin nor the paperclip-gem (which I use) are used correctly, maybe thats a problem to look at too?

Further my versions:

Ruby version    1.9.2 (x86_64-linux)
RubyGems version    1.7.1
Rack version    1.2
Rails version   3.0.4
Active Record version   3.0.4
Action Pack version 3.0.4
Active Resource version 3.0.4
Action Mailer version   3.0.4
Active Support version  3.0.4

Can't tell the exact attachment_fu version... :/ Paperclip version is this:

paperclip (2.3.8)

My album model is this:
# == Schema Information
# Schema version: 20110404082122
#
# Table name: albums
#
#  id         :integer         not null, primary key
#  name       :string(255)
#  location   :string(255)
#  date       :date
#  created_at :datetime
#  updated_at :datetime
#

class Album < ActiveRecord::Base
  has_many  :images,
        :attributes => true,
        :discard_if => proc { |upload| upload.photo_file_size.nil? }
end

and my image model is like this:

# == Schema Information
# Schema version: 20110404082122
#
# Table name: images
#
#  id          :integer         not null, primary key
#  name        :string(255)
#  date        :date
#  landscape   :boolean
#  flash       :boolean
#  cameramaker :string(255)
#  cameramodel :string(255)
#  lens        :string(255)
#  flength     :string(255)
#  aperture    :string(255)
#  exposure    :string(255)
#  iso         :string(255)
#  album_id    :integer
#  filesize    :integer
#  created_at  :datetime
#  updated_at  :datetime
#

require 'RMagick'

class Image < ActiveRecord::Base
  belongs_to :album
  has_attached_file :photo,
            :styles => {
              :thumb => ["150x150", :jpg],
              :pagesize => ["500x400", :jpg],
            },
            :default_style => :pagesize
end

Do you need anything more? I don't understand what the problem is.. I think the attachment_fu plugin is too old or I missed something to say rails to use it...?

Thanks for your time!

Wanye

m_sc
  • 154
  • 7

1 Answers1

1

http://apidock.com/rails/ActiveRecord/Associations/ClassMethods/has_many

There is no any :attributes or :discard_if options for has_many association

Looks like in that tutorial author used attribute_fu plugin. So you need to install it

https://github.com/jamesgolick/attribute_fu

fl00r
  • 82,987
  • 33
  • 217
  • 237
  • So I should use has_attachment instead? Because at [link]http://www.mfischer.com/wordpress/2009/02/02/multiple-image-upload-and-crop-with-rails/ he uses has_many with those attributes... – m_sc Apr 04 '11 at 10:10
  • I did, which seems not very operatable... Since this is the Output: `[me@pc gallery]$ rails plugin install http://github.com/woahdae/attachment_fu.git -r rails3 Initialized empty Git repository in /home/wayne/DEV/ror/gallery/vendor/plugins/attachment_fu/.git/ remote: Counting objects: 71, done. remote: Compressing objects: 100% (67/67), done. remote: Total 71 (delta 11), reused 25 (delta 0) Unpacking objects: 100% (71/71), done. From http://github.com/woahdae/attachment_fu * branch rails3 -> FETCH_HEAD` And more output ommitted which says how to work with the plugin. – m_sc Apr 04 '11 at 12:01
  • I've never used this plugin. Did you restarted your app? – fl00r Apr 04 '11 at 12:04
  • Yes, restarted rails server more than once. Maybe it's not working correctly with rails 3.0.4 :/ – m_sc Apr 04 '11 at 12:05
  • check out documentation of the plugin. I don't like to use them – fl00r Apr 04 '11 at 12:06
  • `gallery/vendor/plugins/attachment_fu/app/views` is in the show env dump... Maybe I find something about this plugin installation (which I didn't as I searched last three times -.-). I like gems much more : – m_sc Apr 04 '11 at 12:10
  • try `rails plugin install git://github.com/giraffesoft/attribute_fu.git` – fl00r Apr 04 '11 at 12:19
  • Yes, tried that too, but I get: `fatal: remote error: Could not find Repository giraffesoft/attribute_fu` because they moved it to [github.com/jamesgolick] but there is no attribute_fu anymore /o\ – m_sc Apr 04 '11 at 15:57
  • Oh noez :O They moved it away, but yeah attribute_fu is what I needed... Blindingly searched for attachment_fu :( Sorry! Thanks so much! – m_sc Apr 04 '11 at 16:05
  • [http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html] So this is what I need if I want up-to-date code :) – m_sc Apr 04 '11 at 16:23