3

I'm using the Trailblazer gem with Rails, and there's a Cell class inside one of my Trailblazer operations that starts throwing a superclass mismatch error whenever I change the code with the server running.

If I start the server and immediately start navigating the site, everything runs fine.

However, if change some code any time after starting the server, and then try to load a page on the site, I get a superclass mismatch error.

neurodynamic
  • 4,294
  • 3
  • 28
  • 39

2 Answers2

2

Turns out the name of my operation was not the same as the name of the file I created for the operation. I had recently changed the filename from register.rb to make_reservation.rb, but hadn't changed the operation class name from Register to MakeReservation. When I made the class name change as well, the superclass mismatch error stopped happening.

neurodynamic
  • 4,294
  • 3
  • 28
  • 39
1

If you are toying with the Trailblazer book with Rails 5-pre you would need to watch out for the change in name spacing. Not having the name spacing properly resulted in a similar error.

Although in Rails 4, models inherit from ActiveRecord::Base in Rails 5 it is form ApplicationRecord.

Your app/concepts/thing/operation.rb in my case app/concepts/listing/operation.rb should be some thing like...

class Listing < ApplicationRecord
  class Create < Trailblazer::Operation
    def process(params)
      @model = Listing.create(params[:listing])
    end
  end
end
Ziyan Junaideen
  • 3,270
  • 7
  • 46
  • 71