Skip to content

Instantly share code, notes, and snippets.

<%= @profile.showable_videos.each do |v| %>
<%= User.find_by_id(v.user_id).name showed the song Video.find_by_id(v.video_id).title to you. %>
<% end %>
def notification_go
current_user.render_read
respond_to do |format|
format.html
format.js
end
end
NOTIFICATIONS_CONDITION = 'some SQL'
has_many :user_notifications
has_many :notifications, :through => :user_notifications,
:conditions => NOTIFICATIONS_CONDITION,
:order => "timeline_events.created_at DESC"
ActiveRecord::StatementInvalid in Videos#index
Showing /rubyprograms/dreamstill/app/views/videos/index.html.erb where line #12 raised:
SQLite3::SQLException: no such table: user_notifications: SELECT COUNT(*) FROM "timeline_events" INNER JOIN "user_notifications" ON "timeline_events".id = "user_notifications".notification_id WHERE (("user_notifications".user_id = 58) AND ..........
ActiveRecord::HasManyThroughSourceAssociationNotFoundError in Videos#index
Showing /rubyprograms/dreamstill/app/views/videos/index.html.erb where line #12 raised:
Could not find the source association(s) :notification or :notifications in model UserNotification. Try 'has_many :notifications, :through => :user_notifications, :source => <name>'. Is it one of :user?
has_many :user_notifications
NOTIFICATIONS_CONDITION = '(actor_type = \'User\' AND ((secondary_subject_type = \'Video\' AND secondary_subject_id IN (SELECT id FROM videos WHERE user_id = #{id})) OR (secondary_subject_type = \'User\' AND secondary_subject_id = #{id})))'
has_many :notifications, :through => :user_notifications,
:finder_sql => 'SELECT timeline_events.* FROM timeline_events
WHERE ' + NOTIFICATIONS_CONDITION + '
ORDER BY timeline_events.created_at DESC'
@meltzerj
meltzerj / Logs
Created May 7, 2011 05:51
This is in the logs when I send a POST request to create a vote.
AREL (0.3ms) UPDATE "users" SET "new_notification_count" = -1, "updated_at" = '2011-05-07 08:48:13.440257' WHERE "users"."id" = 57
def erase_notification_count
self.new_notification_count = (self.notifications.count * (-1))
self.save
end
def notification_count
if self.new_notification_count.nil?
new_notification_count = 0
end
self.new_notification_count += self.notifications.count
def notification_count(user)
new_notifcation_count = new_notification_count || 0
new_notification_count = new_notification_count + user.notifications.count
return new_notification_count
end
def erase_notification_count
new_notification_count = current_user.notifications.count * (-1)
end
Missing partial notifications/comment_added with {:formats=>[:html], :handlers=>[:builder, :rjs, :rhtml, :erb, :rxml], :locale=>[:en, :en]} in view paths "/rubyprograms/dreamstill/app/views"