Reputation: 1901
I've followed all guides and answers, and everything displays correctly, but the actual upload doesn't happen :(
Here's in my ActiveAdmin:
form :html => { :enctype => "multipart/form-data" } do |f|
f.inputs do
f.input :name
f.input :image, :multipart => true
end
end
Here's in my model:
has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :path => ":rails_root/app/assets/images/article_images/:id/:style_:basename.:extension"
I've tried without a path also, didn't work.
Here's my migration:
class AddAttachmentImageToArticle < ActiveRecord::Migration
def self.up
add_column :articles, :image_file_name, :string
add_column :articles, :image_content_type, :string
add_column :articles, :image_file_size, :integer
add_column :articles, :image_updated_at, :datetime
end
def self.down
remove_column :articles, :image_file_name
remove_column :articles, :image_content_type
remove_column :articles, :image_file_size
remove_column :articles, :image_updated_at
end
end
Upvotes: 2
Views: 1256
Reputation: 2620
Just for complete your answer it's necessary do somethings to work.
Add the gems:
gem 'paperclip'
gem 'fog'
Add the configuration of config/application.rb
config.paperclip_defaults = {:storage => :fog,
:fog_credentials => {:provider => "Local",
:local_root => "#{Rails.root}/public"},
:fog_directory => "",
:fog_host => "http://localhost:3000"}
And to show the images at index just added this code:
index do
column "Image" do |epc|
link_to(image_tag(epc.imagem.url(:thumb), :height => '100'), admin_epc_path(epc))
end
default_actions
end
Upvotes: 0