diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb
index 0857378d1..0c88f0ef5 100644
--- a/app/controllers/people_controller.rb
+++ b/app/controllers/people_controller.rb
@@ -84,7 +84,7 @@ class PeopleController < ApplicationController
end
def show
- @person = Person.find_from_id_or_username(params)
+ @person = Person.find_from_guid_or_username(params)
if remote_profile_with_no_user_session?
raise ActiveRecord::RecordNotFound
@@ -139,7 +139,7 @@ class PeopleController < ApplicationController
end
def contacts
- @person = Person.find_by_id(params[:person_id])
+ @person = Person.find_by_guid(params[:person_id])
if @person
@contact = current_user.contact_for(@person)
@aspect = :profile
@@ -154,7 +154,7 @@ class PeopleController < ApplicationController
end
def aspect_membership_dropdown
- @person = Person.find(params[:person_id])
+ @person = Person.find_by_guid(params[:person_id])
if @person == current_user.person
render :text => I18n.t('people.person.thats_you')
else
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 72c1ccbd7..75f3a9581 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -108,7 +108,7 @@ class UsersController < ApplicationController
render :xml => director.build(ostatus_builder), :content_type => 'application/atom+xml'
end
- format.any { redirect_to person_path(user.person.id) }
+ format.any { redirect_to person_path(user.person) }
end
else
redirect_to multi_stream_path, :error => I18n.t('users.public.does_not_exist', :username => params[:username])
diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb
index c47a8f2c0..5a9d5be46 100644
--- a/app/helpers/people_helper.rb
+++ b/app/helpers/people_helper.rb
@@ -31,7 +31,7 @@ module PeopleHelper
def person_link(person, opts={})
opts[:class] ||= ""
opts[:class] << " self" if defined?(user_signed_in?) && user_signed_in? && current_user.person == person
- remote_or_hovercard_link = "/people/#{person.id}".html_safe
+ remote_or_hovercard_link = Rails.application.routes.url_helpers.person_path(person).html_safe
"#{h(person.name)}".html_safe
end
diff --git a/app/models/person.rb b/app/models/person.rb
index 55fd3fa17..0fce8ebe1 100644
--- a/app/models/person.rb
+++ b/app/models/person.rb
@@ -14,6 +14,7 @@ class Person < ActiveRecord::Base
acts_as_api
api_accessible :backbone do |t|
t.add :id
+ t.add :guid
t.add :name
t.add lambda { |person|
person.diaspora_handle
@@ -61,7 +62,7 @@ class Person < ActiveRecord::Base
scope :searchable, joins(:profile).where(:profiles => {:searchable => true})
scope :remote, where('people.owner_id IS NULL')
scope :local, where('people.owner_id IS NOT NULL')
- scope :for_json, select('DISTINCT people.id, people.diaspora_handle').includes(:profile)
+ scope :for_json, select('DISTINCT people.id, people.guid, people.diaspora_handle').includes(:profile)
# @note user is passed in here defensively
scope :all_from_aspects, lambda { |aspect_ids, user|
@@ -95,9 +96,9 @@ class Person < ActiveRecord::Base
self.profile ||= Profile.new unless profile_set
end
- def self.find_from_id_or_username(params)
+ def self.find_from_guid_or_username(params)
p = if params[:id].present?
- Person.where(:id => params[:id]).first
+ Person.where(:guid => params[:id]).first
elsif params[:username].present? && u = User.find_by_username(params[:username])
u.person
else
@@ -107,6 +108,10 @@ class Person < ActiveRecord::Base
p
end
+ def to_param
+ self.guid
+ end
+
def self.search_query_string(query)
query = query.downcase
like_operator = postgres? ? "ILIKE" : "LIKE"
@@ -273,10 +278,11 @@ class Person < ActiveRecord::Base
opts ||= {}
json = {
:id => self.id,
+ :guid => self.guid,
:name => self.name,
:avatar => self.profile.image_url(:thumb_medium),
:handle => self.diaspora_handle,
- :url => "/people/#{self.id}",
+ :url => Rails.application.routes.url_helpers.person_path(self),
}
json.merge!(:tags => self.profile.tags.map{|t| "##{t.name}"}) if opts[:includes] == "tags"
json
diff --git a/app/views/templates/comment.handlebars b/app/views/templates/comment.handlebars
index 5e7b48877..48d832b01 100644
--- a/app/views/templates/comment.handlebars
+++ b/app/views/templates/comment.handlebars
@@ -7,13 +7,13 @@
{{/if}}
-
+