Skip to content

Commit

Permalink
ProfilesController
Browse files Browse the repository at this point in the history
  • Loading branch information
atd committed Mar 22, 2011
1 parent 4bbe831 commit 4fbe5b6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions app/controllers/profiles_controller.rb
@@ -0,0 +1,3 @@
class ProfilesController < InheritedResources::Base
belongs_to *(SocialStream.subjects + [{ :polymorphic => true, :finder => :find_by_slug!, :singleton => true }])
end
7 changes: 7 additions & 0 deletions app/models/profile.rb
Expand Up @@ -29,10 +29,17 @@ def birthday=(value)
end
end

# The subject of this profile
def subject
actor.try(:subject)
end

private

def validate_birthday
errors.add(:birthday, "is invalid. Please, use \"month/day/year\" format and make sure you choose a valid date" ) if (@birthday_formatted_invalid) || (birthday.present? && !birthday.blank? && birthday > Date.today)
end



end
1 change: 1 addition & 0 deletions app/views/profiles/show.html.erb
@@ -0,0 +1 @@
This is the profile for <%= link_to @profile.subject.name, @profile.subject %>
12 changes: 8 additions & 4 deletions config/routes.rb
Expand Up @@ -13,11 +13,14 @@
match 'api/user/:id/home' => 'api#activity_atom_feed', :format => 'atom'
##/API##

resources :users
SocialStream.subjects.each do |actor|
resources actor.to_s.pluralize do
resource :profile
end
end

resource :representation

resources :groups
resources :logos

namespace :mailbox do
Expand All @@ -36,6 +39,7 @@
end


resources :posts
resources :comments
(SocialStream.objects - [ :actor ]).each do |object|
resources object.to_s.pluralize
end
end

0 comments on commit 4fbe5b6

Please sign in to comment.