The Carrierwave gem provides a simple and extremely flexible way to upload files from Ruby applications. It works well with Rack based web applications, such as Ruby on Rails.
We wrote a small application that demonstrates how Rails 3.2.13, Carrierwave, a9s Swift Service and PostgreSQL work together. You can find the example app on GitHub. This application is an adaptation of n0ne's Rails-Carrierwave-jQuery-File-Upload application. You can use this application to do a test run on anyines.com.
The a9s_swift gem
The example application uses the a9s_swift gem which provides simple configuration of the anynines Swift service within your applications. The gem supports Paperclip, CarrierWave and Fog configuration out of the box. We just need to add the gem to the Gemfile and add an initializer for Carrierwave to connect Carrierwave to Swift.
If you’d like to dive deeper into the a9s_swift_gem feel free to browse the Utility class.
Clone the git repository
$ git clone https://github.com/anynines/rails4_carrierwave_example.git $ cd rails4_carrierwave_example $ bundle
Create a database and run migrations
$ rake db:create db:migrate
Run the rails server
$ bundle exec rails s
Access your web application in the browser via localhost:3000
Deploy the application to anynines
Install the a9s gem
$ gem install a9s
Edit the deployment manifest
$ cp manifest.yml.example manifest.yml $ vim manifest.yml
... and exchange all occurrences of your_app_name with your desired application identifier.
The Ruby buildpack is referenced within the provided manifest.yml.example. This buildpack is needed to support Rails 4 and Ruby 2.
Deploy your application
$ cf push
Please sign in to leave a comment.