Attachment_fu thumbnails


#1

howdy!
I had the problem that attachment_fu didn’t make a thumbnail, but
everything else worked. I read this post
http://www.ruby-forum.com/topic/104213 and added a parent_id column. now
I get the following error when I trie to add a photo:

undefined method `find_or_initialize_by_thumbnail_and_parent_id’ for
Photo:Class

my code is:

class Photo < ActiveRecord::Base
has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 1.megabyte,
:thumbnails => { :thumb => ‘164x164>’ }
end

create_table :photos do |t|
t.column :filename, :string
t.column :posted_on, :datetime
t.column :description, :text
t.column :name, :string
end

def create
@photo = Photo.new(params[:photo])
if @photo.save
redirect_to :action => ‘list’
else
render :action => ‘new’
end
end


#2

undefined method `find_or_initialize_by_thumbnail_and_parent_id’ for

The plugin is written for rails 1.2. I have an old tagged
acts_as_attachment plugin for 1.1.6:
http://svn.techno-weenie.net/projects/plugins/tags/acts_as_attachment-1.1.6/


Rick O.
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com


#3

thanks, but i’m using rails 1.2.2


#4

schaf88 wrote in post #236924:

howdy!
I had the problem that attachment_fu didn’t make a thumbnail, but
everything else worked. I read this post
http://www.ruby-forum.com/topic/104213 and added a parent_id column. now
I get the following error when I trie to add a photo:

undefined method `find_or_initialize_by_thumbnail_and_parent_id’ for
Photo:Class

my code is:

class Photo < ActiveRecord::Base
has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 1.megabyte,
:thumbnails => { :thumb => ‘164x164>’ }
end

create_table :photos do |t|
t.column :filename, :string
t.column :posted_on, :datetime
t.column :description, :text
t.column :name, :string
end

def create
@photo = Photo.new(params[:photo])
if @photo.save
redirect_to :action => ‘list’
else
render :action => ‘new’
end
end

My first guess, You don’t have ‘thumbnail’ column in your database
table.
The clue is in the error message:
‘find_or_initialize_by_thumbnail_and_parent_id’, means attachment_fu
looks for both ‘thumbnail’ and ‘parent_id’ column

My db table looks something like this and it works fine.
create_table :photos do |t|
t.string :filename, :null => false
t.string :content_type
t.string :thumbnail
t.integer :size
t.integer :width
t.integer :height
t.integer :parent_id
t.integer :album_id