Last active
August 29, 2015 14:26
-
-
Save maxcodes/b375074fd1978d003f3d to your computer and use it in GitHub Desktop.
Trying to extend PublicActivity::Activity, as per https://github.com/chaps-io/public_activity/issues/219
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If I debug here and execute the code on activity.rb manually, it works | |
<i class="fa fa-heart-o"> <%= @notification.activity.likes.count %></i> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PublicActivity::Activity.class_eval do | |
has_many :notifications, dependent: :destroy | |
has_many :likes dependent: :destroy | |
default_scope { order("created_at DESC") } | |
acts_as_commentable | |
# ... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NoMethodError in Notifications#index | |
Showing /Users/max/Sites/beek_core/app/views/likes/_like.html.erb where line #7 raised: | |
undefined method `likes' for #<PublicActivity::Activity:0x007fce28923be8> | |
</div> | |
<div class="like-actions col-xs-12 "> | |
<%= button_tag class: "btn btn-clear" do %> | |
<i class="fa fa-heart-o"> <%= activity.likes.count %></i> | |
<% end %> | |
</div> | |
Trace of template inclusion: app/views/likes/_like_form.html.erb, app/views/likes/_likes.html.erb, app/views/public_activity/requote/_create.html.erb, app/views/notifications/index.html.erb | |
Application Trace | Framework Trace | Full Trace | |
app/views/likes/_like.html.erb:7:in `block (2 levels) in _app_views_likes__like_html_erb__960950172323955188_70261669470140' | |
app/views/likes/_like.html.erb:6:in `block in _app_views_likes__like_html_erb__960950172323955188_70261669470140' | |
app/views/likes/_like.html.erb:1:in `_app_views_likes__like_html_erb__960950172323955188_70261669470140' | |
app/views/likes/_like_form.html.erb:6:in `_app_views_likes__like_form_html_erb___3672910560343865564_70261711519500' | |
app/views/likes/_likes.html.erb:2:in `_app_views_likes__likes_html_erb__1170604903718584864_70261711484200' | |
app/views/public_activity/requote/_create.html.erb:21:in `_app_views_public_activity_requote__create_html_erb___283162167780977135_70261705374400' | |
app/views/notifications/index.html.erb:9:in `_app_views_notifications_index_html_erb__93827823533085397_70261702907180' | |
Request | |
Parameters: | |
None | |
Headers: | |
None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Notification < ActiveRecord::Base | |
belongs_to :activity, class_name: "::PublicActivity::Activity" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment