Skip to content

ActiveRecord::RecordNotFound #159

Answered by trimngo
trimngo asked this question in Q&A
Discussion options

You must be logged in to vote

Of course when I ask the question I figure out the answer
What I do is I run .to_json on each notification
For notifications that trigger an exception I don't add that to a new list I'm creating
I return that new filtered list

There is probably a more efficient way to do this and I still need to clean out the database of stale entries which I could use help with

  def list
    activities = Notification.where(recipient_id: @current_user.id)

    filt_activities =[]
    for a in activities
      begin
        temp=a.to_json
        filt_activities.append(a)
      rescue ActiveRecord::RecordNotFound
        nil
      end
    end

    render json: {
        status: :found,
        activities:…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by trimngo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants