https://github.com/ging/avatars_for_rails
A Rails gem to manage avatars
https://github.com/ging/avatars_for_rails
Last synced: about 1 year ago
JSON representation
A Rails gem to manage avatars
- Host: GitHub
- URL: https://github.com/ging/avatars_for_rails
- Owner: ging
- License: mit
- Created: 2011-04-11T07:16:26.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2015-03-04T09:08:58.000Z (over 11 years ago)
- Last Synced: 2025-05-07T21:04:30.242Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 789 KB
- Stars: 46
- Watchers: 9
- Forks: 27
- Open Issues: 5
-
Metadata Files:
- Readme: README.rdoc
- License: MIT-LICENSE
Awesome Lists containing this project
README
= Avatars For Rails
Avatars For Rails is a integral solution to provide a model with avatar support.
It includes a database migration and views with jquery.fileupload and jquery.jcrop
It relies on paperclip and imagemagick
= Installation
Add to your Gemfile:
gem 'avatars_for_rails'
and run:
bundle update
Then, if you have a class named user and you want it to have avatars, run:
rails generate avatars_for_rails:install user
This will generate the following:
* A initializer file with configuration for avatars_for_rails.
* A migration providing the database schema for using avatars_for_rails with the user class.
Do not forget to migrate your database
rake db:migrate
In your model, you must include:
class User < ActiveRecord::Base
acts_as_avatarable
end
For rendering the new avatar form:
<%= render partial: 'avatars/form',
object: @user,
as: :avatarable %>
You must include the javascript and css files
//= require avatars_for_rails
If you want to get an user's avatar you can do:
user.logo
For rendering an image_tag for an user's avatar:
<%= image_tag(user.logo.url(:style) ) %>