Skip to content

Commit

Permalink
FIXED avatar_profile_link error
Browse files Browse the repository at this point in the history
installed 'better_errors' and 'rails-erd'
$ brew install graphviz
+ Gemfile
~ gem 'better_errors'
~ gem 'binding_of_caller'
~ gem 'rails-erd'
$ bundle

$ rake erd
  • Loading branch information
TheEricMiller committed May 14, 2013
1 parent 74e4b55 commit 267f199
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 13 deletions.
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ group :test do
gem 'factory_girl_rails'
end

group :development do
gem 'better_errors'
gem 'binding_of_caller'
gem 'rails-erd'
end

group :development, :test do
gem 'sqlite3'
gem 'log_buddy'
Expand Down
17 changes: 17 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,18 @@ GEM
nokogiri (>= 1.4.4)
uuidtools (~> 2.1)
bcrypt-ruby (3.0.1)
better_errors (0.8.0)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
binding_of_caller (0.7.1)
debug_inspector (>= 0.0.1)
builder (3.0.4)
choice (0.1.6)
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.1)
climate_control (>= 0.0.3, < 1.0)
coderay (1.0.9)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
Expand All @@ -47,6 +54,7 @@ GEM
execjs
coffee-script-source (1.6.2)
daemons (1.1.9)
debug_inspector (0.0.2)
devise (2.2.4)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
Expand Down Expand Up @@ -109,6 +117,11 @@ GEM
activesupport (= 3.2.13)
bundler (~> 1.0)
railties (= 3.2.13)
rails-erd (1.1.0)
activerecord (>= 3.0)
activesupport (>= 3.0)
choice (~> 0.1.6)
ruby-graphviz (~> 1.0.4)
railties (3.2.13)
actionpack (= 3.2.13)
activesupport (= 3.2.13)
Expand All @@ -121,6 +134,7 @@ GEM
json (~> 1.4)
request_store (1.0.5)
rmagick (2.13.2)
ruby-graphviz (1.0.9)
sass (3.2.8)
sass-rails (3.2.6)
railties (~> 3.2.0)
Expand Down Expand Up @@ -164,6 +178,8 @@ PLATFORMS

DEPENDENCIES
aws-sdk
better_errors
binding_of_caller
coffee-rails (~> 3.2.1)
devise
draper (~> 1.0)
Expand All @@ -175,6 +191,7 @@ DEPENDENCIES
paperclip
pg
rails (= 3.2.13)
rails-erd
rmagick
sass-rails (~> 3.2.3)
shoulda
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ def can_display_status?(status)
signed_in? && !current_user.has_blocked?(status.user) || !signed_in?
end

def avatar_profile_link(user, image_options={}, html_options={})
avatar_url = user.avatar? ? user.avatar.url(:thumb) : nil #user.gravatar_url
link_to(image_tag(avatar_url, image_options), profile_path(user.profile_name), html_options)
def avatar_profile_link(thisuser, image_options={}, html_options={})
avatar_url = thisuser.avatar? ? thisuser.avatar.url(:thumb) : thisuser.gravatar_url #nil
link_to(image_tag(avatar_url, image_options), profile_path(thisuser.profile_name), html_options)
end

def flash_class(type)
Expand Down
17 changes: 16 additions & 1 deletion app/models/document.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
class Document < ActiveRecord::Base
attr_accessible :attachment, :remove_attachment
has_attached_file :attachment

has_attached_file :attachment,
path: ":attachment/:basename.:extension"

validates_attachment :attachment,
size: { :in => 0..5.megabytes },
content_type: { :content_type => [
'image/jpeg',
'image/jpg',
'image/png',
'text/plain',
'audio/mpeg',
'application/pdf',
'application/zip'
]}


attr_accessor :remove_attachment

Expand Down
23 changes: 15 additions & 8 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,23 @@ class User < ActiveRecord::Base
conditions: { state: 'accepted' }
has_many :accepted_friends, through: :accepted_user_friendships, source: :friend

has_attached_file :avatar, styles: {
large: "800x800>",
medium: "300x200>",
small: "260x180>",
thumb: "80x80#"
has_attached_file :avatar,
path: ":attachment/:id_:basename_:style.:extension",
styles: {
large: ["800x800>", :jpg],
medium: ["300x200>", :png],
small: ["260x180>", :png],
thumb: ["80x80#", :png]
}
validates_attachment :avatar,
content_type: { :content_type => ['image/jpeg', 'image/jpg', 'image/png'] },
size: { :in => 0..3.megabytes }


def self.get_gravatars
all.each do |user|
if !user.avatar?
if !user.avatar.exists?

user.avatar = URI.parse(user.gravatar_url)
user.save
print "."
Expand All @@ -68,8 +75,7 @@ def gravatar_url
stripped_email = email.strip
downcased_email = stripped_email.downcase
hash = Digest::MD5.hexdigest(downcased_email)

"http://gravatar.com/avatar/#{hash}?d=mm"
"http://gravatar.com/avatar/#{hash}.jpg?d=mm&s=900"
end


Expand All @@ -81,3 +87,4 @@ def has_blocked?(other_user)


end

1 change: 0 additions & 1 deletion app/views/statuses/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<div class="status">
<div class="row">
<div class="span1">
<%#= link_to image_tag(status.user.gravatar_url), profile_path(status.user) %>
<%= avatar_profile_link status.user, {}, class: 'pull-left' %>
</div>
<div class="span7">
Expand Down
Binary file added erd.pdf
Binary file not shown.

0 comments on commit 267f199

Please sign in to comment.