Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1017487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:42:46+00:00 2026-05-16T10:42:46+00:00

At the moment, any logged in user can go to http://localhost:3000/notes/note_id and view the

  • 0

At the moment, any logged in user can go to http://localhost:3000/notes/note_id and view the note there. How do I restrict this so that you can only see notes that belong to you? Thanks for reading.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:42:46+00:00Added an answer on May 16, 2026 at 10:42 am

    In the NotesController #show action, redirect or show a permission denied error if the user_id on the note doesn’t == the logged in user id.

    Another solution is to put this code in a before_filter in the NotesController, since the same validation is performed for the #edit and #delete methods.

    Edit: Putting all the suggestions together (Sorry if this has been confusing):

    Edit2: Using Veeti’s association answer, which I always seem to forget, we can add current_user.notes.find() to the mix. Like he said, your current_user needs to return a User object, and you’ll need a has_many :notes in your User model.

    class NotesController < ApplicationController
      before_filter :check_ownership, :except => [:new, :create, :index]
    
      #.. new, create, index, show, edit, delete actions
    
      private
    
      def check_ownership
        redirect_to :back unless current_user.notes.find(params[:id])
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently started learning JavaFX. At the moment I can't build any JavaFX project
I have an IE plugin written in C#. In any moment the user will
At moment I want to implement picture upload without using any plug-ins. My upload
I'm slightly puzzled with what should log out a user. At the moment I
I am working on an image gallery at the moment. When a user is
NOTE: I know the various reasons to avoid using the session, but this is
This problem has driven me mad for over a day now. I can create
Doing something like this at the moment: try { while ((bytesRead = clientStream.Read(data, 0,
Is there any Controls to show tables/trees from DB on-line? I mean without loading
I am working on an app which requires that the user be logged in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.