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
You’re question is a little vague, because it’s not clear what a
bidis 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
acceptedboolean field set totrue.If that is close to what you’re trying to do, then the code below should accomplish that.
in
app/controllers/bids_controller.rbThen you need to add a route for this action to your
config/routes.rbfile. Something like…Form the view, you would link to this route like this:
And if you call
rake routesfrom your command line, you should see an entry that looks like this: