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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:45:33+00:00 2026-06-01T08:45:33+00:00

I have a rails 3.2 project. There are a bid object and i want

  • 0

I have a rails 3.2 project.
There are a bid object and i want the user to be able to accept this bid!
How can i do this?
My first thought is about to make a new method on bids controller and in the method i have to update the accept boolean of bid.Something like that?

  def accept
    @bid = Bid.find(params[:id])
    @bid.subject ='accept!!!!'
    flash[:notice] = "Successfully destroyed post."
    respond_to do |format|
      format.html { redirect_to "/mybids" }
      format.json { head :no_content }
    end
  end
  • 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-01T08:45:35+00:00Added an answer on June 1, 2026 at 8:45 am

    You’re question is a little vague, because it’s not clear what a bid is attached to, or what the other models are in your app, since you don’t say.

    However, let’s say that this is an auction site, and auctions have bids. When a bid is accepted

    • All other bids on that auction are destroyed
    • The bid that was accepted has it’s accepted boolean field set to true.

    If that is close to what you’re trying to do, then the code below should accomplish that.

    in app/controllers/bids_controller.rb

    # PUT /bids/:id/accept
    def BidsController < ApplicationController
      def accept
        @bid = Bid.find(params[:id])
        @bid.update_attribute(:accepted, true)
        @bid.auction.bids.each do |rejected_bid|
          rejected_bid.destroy unless rejected_bid == @bid   # destroys all be the accepted bid
        end
    
        flash[:notice] = "Bid accepted."
        respond_to do |format|
          format.html { redirect_to "/mybids" }
          format.json { head :no_content }
        end
      end
    end
    

    Then you need to add a route for this action to your config/routes.rb file. Something like…

    resources :bids do
      put :accept, :on => :member
    end
    

    Form the view, you would link to this route like this:

    link_to "accept", accept_bid_path(@bid)
    

    And if you call rake routes from your command line, you should see an entry that looks like this:

    accept_bid PUT   /bids/:id/accept(.format)    {:action=>"accept", :controller=>"bids}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Starting a new rails project and we have a well-thought-out color palette, and want
This is my first Rails project. For some reason, I can't post to one
This is not a ruby/rails project deploy. I have the following situation and I
Is there a way to have my Ruby on Rails project reference the Gems
I have a rails 3.1 project using devise for authentication. I have several user
I'm have a Ruby on Rails project which displays illustrations. There are category links
I have a file /public/animals/mammals/pets/d/dog.jpg in the Rails project. So it can be accessed
I have a rails project that I would like to set up email notifications
I have a Rails 3 project. With Rails 3 came Arel and the ability
in a rails project i have to deal with lots of strings, that are

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.