draper decorator changed the 'model' attribute from original model Rails

467 Views Asked by At

I am implementing draper decorators and below is the code.

def edit 
    find_machine!
    puts @machine.model
    authorize! :edit, @machine
end

def find_machine!
    @machine = Machine.find(params[:id])
end

Everything works fine before I added the .decorate method,

def find_machine!
    @machine = Machine.find(params[:id]).decorate
end

class MachineDecorator < Draper::Decorator
    delegate_all
    decorates_finders

    def test_decorate
        'please'
    end
end

Before I add the .decorate method, the @model attributes is what it suppose to be, but after I add the method, the puts output become: #<Machine:0x007fd7e7813500>

What happend?

0

There are 0 best solutions below