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

  • SEARCH
  • Home
  • 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 9251361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:40:45+00:00 2026-06-18T10:40:45+00:00

I have a simple model in RoR and I would like to keep eveything

  • 0

I have a simple model in RoR and I would like to keep eveything people enter on the site. But I also want to be able to hide some content if the user click on “Remove”.

So I added a bolean attribute in my model called “displayed”.

I would like to know, what would be the best-practices-styled method.

I guess I have to change the controller with something like :

def destroy
 @point = Point.find(params[:id])
 @point.displayed = false
 @point.save

respond_to do |format|
  format.html { redirect_to points_url }
  format.json { head :no_content }
end

But I am not sure it is clean. What would be the best way to do it.

As you guess I am noobish with RoR. Chunks of code would be appreciated.

Thank you

  • 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-06-18T10:40:46+00:00Added an answer on June 18, 2026 at 10:40 am

    Something like this:

    class Point < ActiveRecord::Base
    
      def archive        
        update_attribute!(:displayed, false)
      end 
    
    end
    

    And then call @point.archive in the destroy action of your controller where you would normally call @point.destroy. You can also create a default_scope to hide archived points until you explicitly query for them, seethe RoR guide on appling a default scope.

    Edit: Updated my answer as per normalocity & logan’s comments below.

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

Sidebar

Related Questions

I have a simple model from simulink and I would like to generate code
I have a simple model like this: class User < ActiveRecord::Base serialize :preferences end
I have a simple model like this one: class Artist(models.Model): surname = models.CharField(max_length=200) name
I have been trying to create a like button for my RoR 3 site.
I have a simple model like this: class Auction(models.Model): name = models.CharField() class Item(models.Model):
I have a simple model like this: item category --> category <--- items and
I have a simple model which looks like this: class Group(models.Model): name = models.CharField(max_length
I have a simple model define in Django. I want to select an Object
Say I have a simple model like these (small part of a pretty large
I have a simple model like class Interest < ActiveRecord::Base has_and_belongs_to_many :user_profiles end class

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.