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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:16:05+00:00 2026-05-19T23:16:05+00:00

I have submissions that might be in various states and wrote a method_missing override

  • 0

I have submissions that might be in various states and wrote a method_missing override that allows me to check their state with calls like

submission.draft?
submission.published?

This works wonderfully.


I also, for various reasons that might not be so great, have a model called Packlet that belongs_to a meeting and belongs_to a submission. However, I was surprised to find that

packlet.submission.draft?

returns a NoMethodError. On the other hand, if I hard-code a #draft? method into Submission, the above method call works.


How do I get my method_missing methods to be recognized even when the instance is defined via an ActiveRecord association?

  • 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-19T23:16:06+00:00Added an answer on May 19, 2026 at 11:16 pm

    Have you added the draft? method to your respond_to? method for that object? My guess would be that the issue might arise there. What happens when you type:

    submission.respond_to?(:draft?)
    

    To fix this, actually write a respond_to? method like this:

    def respond_to?(method, include_priv = false) #:nodoc:
      case method.to_sym
      when :draft?, :published?
        true
      else
        super(method, include_priv)
      end
    end
    

    My recommendation would be to implement this without using method_missing instead though, so by doing some meta-programming like this:

    class Submission
      [:draft, :published].each do |status|
        define_method "#{status}?" do
          status == "#{status}?"
        end
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails 3 app that displays user submissions in order of how
I've built several apps in rails that have submissions that you can vote on.
I have a site that has user submissions that users can vote on. I
I have a submission table that is very simple: userId, submissionGuid I want to
I have created a html page in php and upon submission i validates that
I have a page that has several ajax submission forms. Each form has a
I have many forms that use AJAX (w/ jQuery) for validation and data submission.
I have a page that have fileupload control, on the submission of the form,
I have a web application that uses a relational database (MySQL). We're adding a
I might be looking at this the wrong way, but I have a form

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.