michelson / dante-stories

A self hosted Medium platform built with Ruby on Rails
https://dante-stories.herokuapp.com/
390 stars 45 forks source link

ERROR: got error uploading file Error: Request failed with status code 500 #25

Closed erosinlove closed 4 years ago

erosinlove commented 4 years ago

Hi, I'm the beginner of rails, react.

ruby version 2.7.0 rails version 6.0.3

I tried to integrate this project into my project. when I uploaded the image to the post I got the error as below

POST http://localhost:3000/posts/test/uploads 500 (Internal Server Error) ==> xhr.js ERROR: got error uploading file Error: Request failed with status code 500 ==> image.js

and this

NoMethodError (undefined method `last' for true:TrueClass):

it's from

def uploads @post = current_user.posts.find(params[:id]) a = @post.images.attach(params[:file]) render json: {url: url_for(a.last)} end

Could you please advice how to fix this