diff --git a/app/models/person.rb b/app/models/person.rb index 1518c64..760371c 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -60,6 +60,14 @@ def full_name "#{first_name} #{last_name}".strip end + def news_items + news + News.where('user_id = ?', user_id) + end + + def event_items + events + Event.where('user_id = ?', user_id) + end + class << self def pdate_profiles_scores diff --git a/app/views/shared/_profile.html.erb b/app/views/shared/_profile.html.erb index 4d1b2b2..66f6abe 100644 --- a/app/views/shared/_profile.html.erb +++ b/app/views/shared/_profile.html.erb @@ -28,25 +28,25 @@ <% end %> <% end %> - <% unless person.news.empty? then %> + <% unless person.news_items.empty? then %>

Related News

- <% person.news.take(10).each do |news| %> + <% person.news_items.take(10).each do |news| %> <%= render partial: 'shared/news', locals: {newsItem: news} %> <% end %> - <% if person.news.size > 10 then %> + <% if person.news_items.size > 10 then %> <%= link_to "View More", news_index_path(person: person.slug) %> <% end %>
<% end %> - <% unless person.events.empty? then %> + <% unless person.event_items.empty? then %>

Related Events

- <% person.events.take(10).each do |event| %> + <% person.event_items.take(10).each do |event| %> <%= render partial: 'shared/event', locals: {event: event} %> <% end %> - <% if person.events.size > 10 then %> + <% if person.event_items.size > 10 then %> <%= link_to "View More", events_path(person: person.slug) %> <% end %>