-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Ember] Uploads service is undefined #301
Comments
You need to inject the uploads service in your route.js file that you're calling |
I'll add that to the issue |
Ok I've tried the below but I get the following error:
I'm investigating this error on the Google but haven't found anything yet. Is this the proper way to inject? I was basing it off of the docs + how auth was injected in the uploads service.
I've also tried:
my file structure is photo > uploads > service.js |
I nested the uploads service inside of photo because symantically, that is where is should go. Try moving the It is used correctly though as |
Got it. Ok moving the uploads/service to app/ solved that problem. However, now when I click to add the photo I get the following error:
and rails is saying:
my params are as follows:
new photo form:
I'm trying to console log both the uploads service and the formData object, but I'm not totally sure where I should be looking in those to see what's not getting through. Thoughts? |
Right after the
|
Also, make the new FormData like this:
instead of |
Confirming that replacing Originally when I console.logged newPhoto.photo_upload it was undefined but with this change I can successfully upload a new file. Muchas gracias @berziiii! |
There's nothing wrong with using jQuery to pass something to FormData. Instead of However, don't do it this way. Some light Googling suggests that in Ember 2, you always have access to the As a side note, just confirming from your most recent comment: -let newPhoto = new FormData(Ember.$('#new-photo-form')); with
+let newPhoto = new FormData(document.getElementById('new-movie-form')); // you meant photo, right? |
|
hi @jrhorn424 I edited my last comment to 'new-photo-form' for clarity, that was a typo on my part. Thanks for the further explanation on Ember jQuery! |
Awesome. In case my last comment wasn't clear, this should work: - let newPhoto = new FormData(document.getElementById('new-photo-form'));
+ let newPhoto = new FormData(event.target); |
Hey @berziiii I'm working on creating a file upload via your instructions (super easy to follow btw thank you!!) and I've run into an issue where 'uploads' is undefined in the route of my new-photo
new-photo/route.js
I'm not sure if I need to inject this service in a particular way? I've tried doing so in the above file but Ember said no. I'm a little lost on how to go about debugging past this point now that I've identified the problem.
Here's the rest of my code:
new-photo-form/template:
new-photo-form/component:
new-photo/template
photo/uploads/service.js:
The text was updated successfully, but these errors were encountered: