I got NoMethodError (undefined method `last' for true:TrueClass):
from app/controllers/posts_controller.rb:71:in `uploads'
Here is the script
def uploads
@post = current_user.posts.friendly.find(params[:id])
a = @post.images.attach(params[:file])
render json: {url: url_for(a.last)}
end
I imagine the 'attach' method is returning 'true' or 'false' as to whether it was successful or not rather than assigning the file to the variable.
Personally I'd remove the variable 'a', then just use:
url_for(@post.images.last)