Skip to content

Instantly share code, notes, and snippets.

@guycall
Last active December 14, 2015 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guycall/5166243 to your computer and use it in GitHub Desktop.
Save guycall/5166243 to your computer and use it in GitHub Desktop.
Below are some instructions to very quickly add file uploading to a Rails 3.1/3.2 app using the gems active_scaffold_vho and carrierwave (https://github.com/vhochstein/active_scaffold & https://github.com/jnicklas/carrierwave )

Added to Gemfile

gem 'render_component_vho'
gem 'active_scaffold_vho'
gem 'kaminari'
gem 'carrierwave'

Run the following commands

bundle install
bundle exec rake db:create
rails generate uploader Avatar
rails g active_scaffold Team name:string avatar:string
bundle exec rake db:migrate

Add the following line to app/assets/javascripts/application.js

//= require active_scaffold

Add the following line to /app/assets/stylesheets/application.css

*= require active_scaffold

Add the following line to /app/models/team.rb

mount_uploader :avatar, AvatarUploader

Run the app and visit localhost:3000/teams

Unfortunately with rails 3.1.11, active_scaffold_vho 3.1.6 & carrierwave 0.5.8 I'm currently getting an error when trying to do the upload:

NoMethodError (undefined method `strip' for #<ActionDispatch::Http::UploadedFile:0xb5f8f81c>):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment