0
votes

I was following a tutorial about developing a DropBox like file sharing platform using dropzone, ruby on rails and Ajax. I created a rails application, integrated dropzone into the project, created paperclip and uploads models. Everything was okay till I edited UPLOADS_CONTROLLER.RB file as follows:

class UploadsController < ApplicationController
  def new
    @upload = Upload.new
  end

  def create
    @upload = Upload.create(upload_params)
    if @upload.save
      render json: { message: "success" }, :status => 200
    else
      #  you need to send an error header, otherwise Dropzone
          #  will not interpret the response as an error:
      render json: { error: @upload.errors.full_messages.join(',')}, :status => 400
    end         
  end

  private
  def upload_params
    params.require(:upload).permit(:image)
  end
end

After editing the file, I reloaded the page and I got the error below. I can't fix the problem. Thanks for your help!

TypeError in UploadsController#new
superclass mismatch for class Upload
Extracted source (around line #3):
1 class Upload ApplicationRecord
2 end
3 class Upload < ActiveRecord::Base
4 has_attached_file :image, :styles => { :medium => "300x300>",:thumb => "100x100>" }
5
6 validates_attachment :image,
Application Trace | Framework Trace | Full Trace app/models/upload.rb:3:in <top (required)>'
app/controllers/uploads_controller.rb:3:in
new'

Link to the tutorial which I mentioned

1
Hi and welcome to Stack Overflow. Here we like to help you, but we prefer not to go down multiple external links to figure out what the problem is. Can you please edit your question and put all relevant information and code into your question so that we don't have to follow any links? Links go stale, and we want Stack overflow to last forever! ;)Taryn East

1 Answers

0
votes

You probably have a UploadsController class defined elsewhere, it could be the second time you declared it or one of your Gems or plugins already defines it.