SimpleStrapFile
Simple Form component that provides a pretty file input using Twitter Bootstrap for styling.
Based on 'Whipping File Inputs Into Shape with Bootstrap 3' by Cory LaViska.
Installation
Prerequisites
It is assumed you have installed Bootstrap and Simple Form already
Ensure you have applied Bootstrap styling to Simple Form using:
rails generate simple_form:install --bootstrap
Gem
Add gem 'simple_strap_file'
to your application's Gemfile and run bundle
.
Assets
Import styling in app/assets/stylesheets/application.css
:
*= require simple_strap_file
Require Javascripts in app/assets/javascripts/application.js
//= require simple_strap_file
Tips
If you are using Paperclip and have an avatar
column you can use the following in your form:
<%= f.input :avatar, input_html: { value: f.object.avatar_file_name, readonly: true } %>
This will also show the filename when the form is shown in the edit view.
Contributing
- Fork it (https://github.com/michaelcowan/simple_strap_file/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request