From dc49719bd2576086cf1f64af2a046ef269e2dc3b Mon Sep 17 00:00:00 2001 From: Nico Date: Wed, 9 Jan 2013 18:30:23 +0100 Subject: [PATCH] note avatar --- Gemfile.lock | 2 ++ app/models/admin.rb | 4 ++-- app/views/admin/admins/_form.html.haml | 7 ++++++- app/views/notes/_note.haml | 3 +-- config/database.yml | 1 - 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 649db0c..c6f58d2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -98,6 +98,7 @@ GEM net-ssh (>= 1.99.1) nokogiri (1.5.6) orm_adapter (0.4.0) + pg (0.14.1) polyglot (0.3.3) posix-spawn (0.3.6) pygments.rb (0.3.7) @@ -174,6 +175,7 @@ DEPENDENCIES kaminari mysql2 nokogiri + pg pygments.rb rails (= 3.2.9) redcarpet diff --git a/app/models/admin.rb b/app/models/admin.rb index 7fcc743..8079820 100644 --- a/app/models/admin.rb +++ b/app/models/admin.rb @@ -9,8 +9,8 @@ class Admin < ActiveRecord::Base attr_accessor :login # Setup accessible (or protected) attributes for your model - attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :name, :firstname + attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :name, :firstname, :file # attr_accessible :title, :body - + mount_uploader :file, AvatarUploader end diff --git a/app/views/admin/admins/_form.html.haml b/app/views/admin/admins/_form.html.haml index 1e278cc..aee3327 100644 --- a/app/views/admin/admins/_form.html.haml +++ b/app/views/admin/admins/_form.html.haml @@ -29,7 +29,12 @@ %tr %td.label= f.label :password_confirmation, "Confirmation :" %td= f.text_field :password_confirmation, :class => "inputText" - + + %tr + %td.label= f.label :file,"image :" + %td + = f.file_field :file + =image_tag(f.object.file.large.thumb.url) if f.object.file .actions diff --git a/app/views/notes/_note.haml b/app/views/notes/_note.haml index 573eb82..2e4a9bd 100644 --- a/app/views/notes/_note.haml +++ b/app/views/notes/_note.haml @@ -4,8 +4,7 @@ .left .user - - =gravatar_image_tag(note.admin.email, :class => "avatar", :gravatar => {:default => "http://#{HOSTNAME}/assets/default_avatar.jpg"}) + =image_tag (note.admin.file? ? note.admin.file.large.thumb.url : ""), :class => "avatar" =note.admin.username .date=l note.created_at, :format => :short diff --git a/config/database.yml b/config/database.yml index 995f03b..48de9f2 100644 --- a/config/database.yml +++ b/config/database.yml @@ -10,7 +10,6 @@ development: database: pic_vert pool: 5 username: root - password: dev socket: /tmp/mysql.sock