Commit 1db5d68d9d43f0be87f95882e3eb1165ec9cc2bf
1 parent
ee03174e
Exists in
master
and in
1 other branch
Using a relation for User#apps rather then method.
Showing
1 changed file
with
2 additions
and
4 deletions
Show diff stats
app/models/user.rb
| ... | ... | @@ -19,6 +19,8 @@ class User |
| 19 | 19 | |
| 20 | 20 | attr_protected :admin |
| 21 | 21 | |
| 22 | + has_many :apps, :foreign_key => 'watchers.user_id' | |
| 23 | + | |
| 22 | 24 | if Errbit::Config.user_has_username |
| 23 | 25 | field :username |
| 24 | 26 | validates_presence_of :username |
| ... | ... | @@ -32,10 +34,6 @@ class User |
| 32 | 34 | self[:per_page] || PER_PAGE |
| 33 | 35 | end |
| 34 | 36 | |
| 35 | - def apps | |
| 36 | - App.where('watchers.user_id' => id) | |
| 37 | - end | |
| 38 | - | |
| 39 | 37 | def watching?(app) |
| 40 | 38 | apps.all.include?(app) |
| 41 | 39 | end | ... | ... |