Skip to content

Commit

Permalink
update building user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
samnang committed Feb 14, 2011
1 parent aa29ba9 commit 4e75f42
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
10 changes: 10 additions & 0 deletions app/helpers/application_helper.rb
Expand Up @@ -17,4 +17,14 @@ def topic_tags(topics)
result << link_to(topic, "/people?topic=#{topic}", :class => 'topic-tag')
end
end

def edit_in_place(object, field, options={})
defaults = {:nil => "Click to edit #{field.to_s.gsub('_', ' ')}"}.merge(options)

if user_signed_in? and current_user.username == @user.username
best_in_place object, field, defaults
else
object.send(field)
end
end
end
4 changes: 2 additions & 2 deletions app/models/user.rb
Expand Up @@ -27,8 +27,8 @@ class User < ActiveRecord::Base

attr_accessor :login

attr_accessible :login, :username, :email, :password, :password_confirmation, :remember_me,
:full_name, :time_zone, :website, :twitter_id, :github_id, :availability
attr_accessible :login, :username, :email, :password, :password_confirmation, :remember_me, :skills,
:full_name, :time_zone, :website, :twitter_id, :github_id, :availability, :about_me

before_create :set_full_name

Expand Down
20 changes: 15 additions & 5 deletions app/views/users/show.html.haml
Expand Up @@ -4,13 +4,23 @@
.photo
= image_tag avatar_url(@user.email, 170)
#user-info
%h1= best_in_place @user, :full_name
%p= best_in_place @user, :about, :type => :textarea, :nil => 'Click to edit about!'
%h1= edit_in_place @user, :full_name
%p=raw edit_in_place @user, :about_me, :type => :textarea, :sanitize => false

%h2 Skills and Interests
.skills
=raw topic_tags('Ruby, Agile, TDD, RSpec, Clean Code, BDD, Algorithm, Metaprogramming, DSL')
%p=raw edit_in_place @user, :skills, :type => :textarea, :sanitize => false

%h2 Available Times
%p= best_in_place @user, :availability, :nil => 'Click to edit availability!'
%p
= edit_in_place @user, :availability
%br
= edit_in_place @user, :time_zone

%h2 Websites
%p
= edit_in_place @user, :website
%br
= edit_in_place @user, :twitter_id
%br
= edit_in_place @user, :github_id

11 changes: 11 additions & 0 deletions db/migrate/20110212162114_add_about_me_and_skills_to_user.rb
@@ -0,0 +1,11 @@
class AddAboutMeAndSkillsToUser < ActiveRecord::Migration
def self.up
add_column :users, :about_me, :text
add_column :users, :skills, :text
end

def self.down
remove_column :users, :about
remove_column :users, :skills
end
end
9 changes: 0 additions & 9 deletions db/migrate/20110212162114_add_about_to_user.rb

This file was deleted.

0 comments on commit 4e75f42

Please sign in to comment.