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)>'
new'
app/controllers/uploads_controller.rb:3:in
Link to the tutorial which I mentioned