An input plugin for formtastic to render file fields with an image preview for paperclip attachments
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
tasks
MIT-LICENSE
README.textile
Rakefile
init.rb

README.textile

FormtasticImage

An extension for Formtastic1 to generate file inputs for paperclip2 fields.

Example

In the model class:

class User < ActiveRecord::Base
  has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
end

And in the view

<% semantic_form_for @user do |form| %>
  <% form.inputs do %>
    <%= form.input :avatar, :as => :image, :preview_size => :thumb %>
  <% end %>
<% end %>

Dependencies

You must have the formtastic gem/plugin and the paperclip gem/plugin added to your application.

Todo

Test, test, test…

References

1 Formtastic @ GitHub

2 Paperclip @ Github

Copyright © 2009 Paul Smith, released under the MIT license