-
-
Save chrislerum/133852 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
has_attached_file :avatar, :styles => {:thumb => '100x100>'} | |
end | |
########### | |
class CreateUsers < ActiveRecord::Migration | |
def self.up | |
create_table :users do |t| | |
t.string :avatar_file_name | |
t.string :avatar_content_type | |
t.integer :avatar_file_size | |
t.datetime :avatar_updated_at | |
# other columns | |
end | |
end | |
def self.down | |
drop_table :users | |
end | |
end | |
########### | |
class UsersController < ApplicationController | |
active_scaffold :users do |config| | |
config.create.multipart = true | |
config.update.multipart = true | |
config.columns.exclude :avatar_file_size, :avatar_updated_at, :avatar_file_name, :avatar_content_type | |
config.columns << :avatar | |
end | |
end | |
########### | |
module UsersHelper | |
def avatar_form_column(record, input_name) | |
file_field :record, :avatar | |
end | |
def avatar_column(user) | |
image_tag user.avatar.url(:thumb) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment