ActiveAdmin doesn't upload image when using Paperclip

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

Answers


The problem was the damn attr_accessible not having :image


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

Need Your Help

iphone modal view - how to go back to parent parent parent controller

iphone modal-dialog modalviewcontroller

I have several views that I open one after another modally. View1 calls View2 and View2 calls View3.

Using php variable in href html links

php html href

here is what i am trying to do

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.