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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:49:13+00:00 2026-06-15T19:49:13+00:00

I am using Ruby on Rails 3.2.9 and Ruby 1.9.3-p125. The scenario is the

  • 0

I am using Ruby on Rails 3.2.9 and Ruby 1.9.3-p125. The scenario is the following:

I implemented a acts_as_customizable plugin and I have an Article model class “acting as customizable”. The plugin, through metaprogramming, adds a method named customize to a Comment model class (note: since that, the plugin has side effects because manipulate the Comment object outside the scope of the Article object).

Given that scenario, when I (re-)start the server and I run @comment.customize then I get the error NoMethodError - undefined method 'customize' for #<Comment:0x0...>. However, when I (re-)start the server and I run the following code then all works as expected:

Article
@comment.customize

If I understood the “evil” part, the above code works because the “simple” call to the Article class before to run the customize method makes it to fire the acts_as_customizable method which in turn adds (through metaprogramming) the customize method to the Comment class.

How should I avoid the “evil”?

  • 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-15T19:49:14+00:00Added an answer on June 15, 2026 at 7:49 pm

    This is caused by lazy/auto loading. To save time rails doesn’t load all classes on startup. Instead, it loads them when necessary. If you never access Article, it’s not loaded and, therefore, Comment is not getting its dynamic methods.

    How should I avoid the “evil”?

    Simple answer: use require_dependency (thanks, @cryo28)

    Correct answer: don’t do evil. Make plugin behaviour more predictable / less confusing. If it’s applied to Article, it should act on Article and not Comment.

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

Sidebar

Related Questions

I am using Ruby on Rails v3.2.2. I have following model classes class Country
I am using Ruby on Rails v3.2.2. I have following associations with an alias_method
I am using Ruby on Rails 3.2.2 and Ruby 1.9.2. Given the following multidimensional
I have a problem running a Ruby on Rails application using Passenger. My application
I am using ruby on rails and have things on my site that users
I'm using Ruby on rails and I have videos that I don't want users
I am using RVM , Ruby v1.9.3-p125 and Ruby on Rails v3.2.2 . On
I am using ruby on rails with a MySQL backend. I have a table
Using Ruby on Rails. I'm trying to sort a query by number (saved as
using Ruby on Rails 2.3.2, since I already created Scaffold for Story, so instead

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.