Skip to content

Commit

Permalink
Add gravater icon to users#show and practices#show
Browse files Browse the repository at this point in the history
  • Loading branch information
hrysd committed Mar 25, 2013
1 parent e58b4be commit 366c889
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/models/practice.rb
Expand Up @@ -3,6 +3,14 @@ class Practice < ActiveRecord::Base
ranks :row_order
as_enum :target, [:everyone, :programmer, :designer]
has_many :learnings

has_many :completed_learnings,
-> { where(status_cd: 1) },
class_name: 'Learning'
has_many :completed_users,
through: :completed_learnings,
source: :user

validates :title, presence: true
validates :description, presence: true
validates :goal, presence: true
Expand Down
6 changes: 6 additions & 0 deletions app/views/practices/show.html.haml
Expand Up @@ -6,3 +6,9 @@
.goal= simple_format rendering(@practice.goal)
= link_to t('edit'), edit_practice_path(@practice), class: 'btn btn-primary'
= link_to t('destroy'), practice_path(@practice), data: { confirm: t('are_you_sure') }, method: :delete, class: 'btn btn-danger'

%h3= t('completed_users')
- @practice.completed_users.each do |user|
.icon
= link_to user do
= gravatar_tag user, size: 50
5 changes: 5 additions & 0 deletions app/views/users/show.html.haml
Expand Up @@ -15,5 +15,10 @@
- if @user.blog_url?
%dt= t('helpers.label.user.blog_url')
%dd= link_to @user.blog_url
%h3= t('completed_practices')
%ul
- @user.completed_practices.each do |practice|
%li
.title= link_to practice.title, practice
- if current_user
= link_to t('edit'), edit_user_path(current_user), class: 'btn btn-primary'

0 comments on commit 366c889

Please sign in to comment.