Image holder is image upload and management tool for Rails.
It is light and does not do anything else than resizing and saving the image file.
In Gemfile, add
gem 'image_holder'In your model do :
class YourModel < ActiveRecord::Base
has_attached_image :ATTR_NAME, default: 'DEFAULT_IMAGE.png', scale: SIZE
end- default: and scale: options are optional Example
Lets say you have a User model with attr name and logo
class User < ActiveRecord::Base
attr_accessor :name, :logo
has_attached_image :logo, default: 'default_user_logo.png', scale: 60
endviews/users/_form.html.erb
<%= form_for @user --- %>
----
----
<%= f.file_field :logo %>
----
----
<%= submit_tag %>
Nothing special, just usual
app/controllers/users_controller.rb
def create
---
---
@user.save
---
---
endImage will be located in
app/assets/images/users/logo<@user.id>.extension
The logo column in users table will store the path of image(logo in this example)
Inside view template do:
<%= image_tag @user.logo %>