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 6752857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:05:36+00:00 2026-05-26T13:05:36+00:00

I have a web app which uses Devise for authentication. It is a site

  • 0

I have a web app which uses Devise for authentication. It is a site which allows the user to upload images so the url would be /images/2. There is a separate image controller.

I have found that a user could edit an image they didn’t upload by changing then URL, e.g. /images/4/edit. Is there a way to block them from editing other users images and only allowing them to edit their own?

The images controller, model, etc was created using rails g scaffold if that helps.

  • 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-26T13:05:37+00:00Added an answer on May 26, 2026 at 1:05 pm

    There are many different solutions for this, but the simplest is when running edit/update/destroy load the image from the current user instead of from all images:

    def edit
      @image = current_user.images.find( params[:id] )
    end
    
    def update
      @image = current_user.images.find( params[:id] )
      # do whatever has to be done
    end
    
    def destroy
      @image = current_user.images.find( params[:id] )
      # do whatever has to be done
    end
    

    Also, using scaffolds is a really bad practice, you should just write our own code, it’s simpler, more productive and will lead you to understand how the framework is supposed to work.

    You could also use nested controllers for this, but you would have to research a bit to understand how they work and why they might be a better solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web app which uses Devise for authentication. It is a site
I have a Silverlight web app which uses ASP.net Website administration tool for user
I have a Flash web app which displays user submitted PNG files. Files are
I have a user profile page on my web app which has contact information.
I have a simple ASP.NET web app which uses a WCF Client to talk
I have a (IE only) web app which now uses htc to render html
I have an existing web app which uses Struts for the forward-action... I am
I have an ASP .NET web application which uses Forms Authentication. Let's call this
I have created a data access layer in my web app which uses ObjectDataSource
I have a web app in Java, which uses some external program (invokes a

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.