Skip to content

Commit

Permalink
added default profile pic
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Sisney committed Mar 21, 2014
1 parent fc7a55c commit 667ef42
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
Binary file added app/assets/images/mickey-mouse-large.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class User < ActiveRecord::Base
mount_uploader :pic, ImageUploader

def self.bmi(user)
if user.weights.last && user.height_feet && user.height_in
if user.weights.last && !user.height_feet.empty? && !user.height_in.empty?
current_weight=user.weights.last.weight.to_f
height_in_inches = (user.height_feet.to_f*12)+user.height_in.to_f
((current_weight*703)/(height_in_inches**2)).round(2)
Expand All @@ -32,15 +32,15 @@ def self.bmi(user)
def self.bmi_translate(bmi)
case bmi
when 0.0..18.4
"underweight"
"- underweight"
when 18.5..24.9
"normal weight"
"- normal weight"
when 25.0..29.9
"overweight"
"- overweight"
when 30.0..100
"obese"
"- obese"
else
"n/a"
""
end
end

Expand Down
5 changes: 4 additions & 1 deletion app/views/users/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
- @users.each do |user|
-next if user == current_user
.prof.backs
%img{src: user.pic_url(:medium)}
-if user.pic_url.nil?
=image_tag("mickey-mouse-large.jpg")
-else
%img{src: user.pic_url}
%h4= link_to user.name, user
%h6= "Goal: #{user.goal}"
-if current_user.friends.include?(user)
Expand Down
12 changes: 9 additions & 3 deletions app/views/users/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
.row
.backs.large-12.columns
.large-3.columns
%img{src: @user.pic_url}
-if @user.pic_url.nil?
=image_tag("mickey-mouse-large.jpg")
-else
%img{src: @user.pic_url}
.large-9.columns
.row
.large-3.columns
Expand All @@ -18,12 +21,15 @@
.large-3.columns
%h4.subheader Goal Weight
.large-9.columns
%h3= @user.goal
-if @user.goal
%h3= @user.goal
-elsif current_user == @user
%h3=link_to "add goal weight", edit_user_registration_path
.row
.large-3.columns
%h4.subheader BMI
.large-9.columns
%h3="#{@bmi} - #{@bmi_translation}"
%h3="#{@bmi} #{@bmi_translation}"
.large-6.columns.no-right-pad
.backs.no-margin
%h3 Past Weights
Expand Down
9 changes: 7 additions & 2 deletions app/views/weights/_weight.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
.weight-box.weightid{"data-id" => weight.id}
.profile-info.columns.large-12
.first-inner-box.large-3
.weight-box-profile_pic= image_tag weight.user.pic
.weight-box-profile_pic
-if weight.user.pic.url.nil?
=image_tag("mickey-mouse-large.jpg")
-else
=image_tag weight.user.pic
.spacing
.inner-box.large-6
.weight-box-name= link_to weight.user.name, user_path(weight.user.id)
Expand All @@ -15,8 +19,9 @@
%span.weight-num #{weight.user.goal}
.weight
Date: #{weight.date}
-if weight.pic
-if weight.pic
%img{src: weight.pic_url(:medium)}
%br
%br
Expand Down
9 changes: 6 additions & 3 deletions app/views/weights/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
= render 'weights/form'
.row
.large-6.large-centered.columns.weights.backs
- @weights.each do |weight|
= render "weight", weight: weight

-if @weights.empty?
=link_to "Add Friends", root_path
-else
- @weights.each do |weight|
= render "weight", weight: weight

0 comments on commit 667ef42

Please sign in to comment.