Hey guys,
I posted this a little while ago but I am still having trouble with it.
I have install acts as attachment. I am using it with one of my existing
models.
Here is the model
class Image < ActiveRecord::Base
acts_as_attachment :storage => :file_system, :max_size =>
300.kilobytes, :content_type => :image
validates_as_attachment
end
I have set up the controller to do this…
def upload_image
@image = Image.new(params[:image])
if @image.save
flash[:notice] = “Image uploaded”
redirect_to :action => “image”
else
flash[:notice] = “Image upload error”
redirect_to :action => “image”
end
end
and this is my view
%= start_form_tag :action => “upload_image”, :multipart => true %>
Upload image form my computer...
<%= file_field("image", "uploaded_data" ) %>
<%= render :partial => “license” %>
<%= submit_tag “Upload” %>
I have got the following in my database
create_table :images do |t|
t.column :filename, :string
t.column :size, :integer
t.column :content_type, :string
t.column :parent_id, :integer
t.column :alt, :string
t.column :resource_id, :int
t.column :thumbnail, :string
t.column :width, :integer
t.column :height, :integer
t.column :url, :string
end
Everytime i go to upload an image i get the following error
undefined method `content_type’ for “image.jpg”:String
Any ideas would be great i am really stumped here