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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:55:22+00:00 2026-05-25T23:55:22+00:00

In the RefineryCMS gem there is a Page model that is used to pull

  • 0

In the RefineryCMS gem there is a Page model that is used to pull in information from the CMS. The model is not defined in your current app and therefore you cannot modify its code (unless you hop into the gem code).

Is there a way to modify the methods within an existing model without having to apply the changes each time a page is loaded? Here is what I have tried:

  1. Model.class_eval

  2. Model.send :include, MixinThatHasNewMethods

I’ve also tried creating a new class with the updated methods and hoping that would update the existing class.

Any ideas?

  • 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-25T23:55:22+00:00Added an answer on May 25, 2026 at 11:55 pm

    Ruby allows the developer to “update” any object, at anytime.

    That means that after Model is loaded by RefineryCMS you can just reopen the class and update it:

    class Model
        def new_method(value)
            ...
        end
    
        def existing_method(*args)
            ...
            super  # refer to the ovewriten method
        end
    end
    

    In your case RafineryCMS is an RoR app, that means while loading the server the ruby code is loaded first for the rails framework, then for the RafineryCMS gem/plugin and after all for your custom libraries (eg: lib folder).

    The important point here is the loading order of the code, modification should be loaded after the genuine class code.

    That is in your lib or initializers (not really a good place but it works) you should put your custome methods for the Model class.

    EDIT: I was reading your question again, and I have to mention, that you are wrong, you actually can change a class from a gem or plugin.
    ruby load every object in the same scope and all objects are accessible to be overwritten.

    In development environment, RoR, reloads all classes (except if cache_classes = false) on every request. It is possible, that after the first request, the gem is reloaded and your changes are lost. Take care to reload your libraries after for every request (only in developement env)

    PS: include & class_eval would work too, the important thing is too overwrite a previously loaded class

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

Sidebar

Related Questions

I have the following custom Refinery CMS engines in my gemfile: gem 'refinerycms-venues', '1.0',
I am trying to update the Refinery CMS gem I have installed on my
Anyone knows if there are any framework or layout that use the Rails Guides
How do you add custom fields in Refinery CMS? That is, I would like
I just updated refinerycms-news engine in my Gemfile from '~> 0.9.8' to :git =>
I'm using refinery cms and want to override (add a method) to their page
Using RefineryCMS, does anyone know if there's a way to fallback to the default
I'm trying to have client-side validation errors show up inline, using the client_side_validations gem
I've developed a website using RefineryCMS, and now the client have asked for a
I have been really stuck on this problem. My validation for my model fails

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.