Skip to content

Rails: Support reloading of classes in development #122

@pfeiffer

Description

At the moment changing a method in a class descending from ContentfulModel::Base requires full reload of Rails environment.

Example:

class TestModel < ContentfulModel::Base
   self.content_type_id = 'test'

   def title
      "This is the title!"
   end
end
# eg. in "rails console"
irb(main):001:0> TestModel.first.title
=> "This is the title!"

Changing the #title method:

....
def title
   "New title?"
end
....

And then reloading:

irb(main):002:0> reload!
Reloading...
=> true

irb(main):003:0> TestModel.first.title
=> "This is the title!" # Would have expected "New title?" here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions