Skip to content

Commit

Permalink
Fixing link to profile for local users in feed.
Browse files Browse the repository at this point in the history
Hopefully nobody is doing remote feeds yet!
  • Loading branch information
wilkie committed Mar 24, 2011
1 parent a2a17b8 commit 2330a63
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 10 additions & 2 deletions models/author.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Author
one :user

# The url of their profile page
key :url, String
key :remote_url, String

def self.create_from_hash!(hsh)
create!(
Expand All @@ -21,10 +21,18 @@ def self.create_from_hash!(hsh)
:website => hsh['user_info']['urls']['Website'],
:bio => hsh['user_info']['description'],
:image_url => hsh['user_info']['image'],
:url => hsh['user_info']['url']
:remote_url => hsh['user_info']['url']
)
end

def url
if remote_url.nil?
"/users/#{username}"
else
remote_url
end
end

def avatar_url
if image_url.nil?
if email.nil?
Expand Down
7 changes: 4 additions & 3 deletions models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ class User

# Make the username required
# However, this will break it when email authorization is used
key :username, String, :unique => true
key :username, String #, :unique => true
key :perishable_token, String

key :email, String #, :unique => true, :allow_nil => true

# eff you mongo_mapper.
validates_uniqueness_of :name, :allow_nil => :true

validates_uniqueness_of :email, :allow_nil => :true
validates_uniqueness_of :username, :allow_nil => :true

belongs_to :author
belongs_to :feed
Expand Down

0 comments on commit 2330a63

Please sign in to comment.