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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:46:35+00:00 2026-05-18T05:46:35+00:00

I defined one of my custom method in PostsController as follows:- class PostsController <

  • 0

I defined one of my custom method in PostsController as follows:-

class PostsController < ApplicationController
 ...<<other methods truncated from display >>
  public
    def update_bid_winner (winner_id)
    @post.bid_winner_id = winner_id
    @post.save
  end  
end  

But when I try to call it from some other controller (BidsController in my case). Where Bid is a nesteded resource of post:-

resources :posts do
  resources :bids do
    member do
      get 'offer_bid'
    end
  end
 end  

I tried to call my custom method as follows from the bids controller :-

 def offer_bid
   @post = Post.find(params[:post_id])
   @bid = Bid.find(params[:id])
   @post.update_bid_winner(@bid.user_id)  <<<<<<<<<< Here goes the call
   @post.save
    redirect_to post_path(@post)
end

But I get an error saying that undefined method update_bid_winner :-

undefined method `update_bid_winner' for #<Post:0xb68114f4>  

Help me out. am I doing anything wrong here? If so , please suggest ways to achieve the same !!

Thanks in Advance.

  • 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-18T05:46:36+00:00Added an answer on May 18, 2026 at 5:46 am

    PostsController and Post are two different classes. Notice how @post is a Post object: @post = Post.find(params[:post_id])

    Define the method in app/models/post.rb instead of app/controllers/posts_controller.rb.

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

Sidebar

Related Questions

hi i defined one class to create cookie by received parameter's from user. when
If I have the core of a class defined in one file as public
I have a small custom object defined as: public class TimeSeriesDefinition { public int
I'm getting a NoMethodError when trying to access a method defined in one of
I have a model like this defined... public class Product{ private long timestamp; //
What's a sound approach to override the CompareTo() method in a custom class with
I have one problem to work with NSMutableData . I defined one NSMutableData *receivedData
I have the following layout defined for one of my Activities: <?xml version=1.0 encoding=utf-8?>
I'm attempting to pass a pointer to a function that is defined in one
I have two Services called TemplateService, TemplateReportService (both defined in one WCF Service Library)

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.