diff options
| author | mo khan <mo@mokhan.ca> | 2015-01-17 12:15:19 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-01-17 12:15:19 -0700 |
| commit | 980df161d60df14af98733057649cdd6ba98deca (patch) | |
| tree | d1e6f078400a283a486bcbaa8fa309f8d1f2a305 /app/models | |
| parent | 6dfba2b4603e2711a40c909361057677d65c72b1 (diff) | |
inline handler to add a cake to someones favorites.
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/user.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index e82edb1d..8594e9bb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,8 +18,9 @@ class User < ActiveRecord::Base has_one :avatar, class_name: 'Photo', as: :imageable acts_as_tagger - def add_favorite(creation) - creation.liked_by(self) + def add_favorite(cake) + return if self.owns(cake) + cake.liked_by(self) end def already_likes(creation) |
