Closed fbottin closed 11 years ago
Hi @fbottin It is impossible to help you if you just say "it appears not work properly" Look for errors in the rails server log or the browser's console log so I can guess what goes wrong in your case..
That's the problem @atd, all appears to be correct. No errors in rails server log or in browser console log. In my opinion after we select the image for upload, they never reach "initFileUpload" function. Don't know if its a problem in avatars_for_rails javascript or inside the jquery.fileupload.
Trying to be more specific, after I followed the documentation, when I loaded the page, the file field appears. But when I selected a picture, the function appears to stop. The name of the picture is on the side of the field, however the application never call the crop function.
I know it's hard to help in a situation like this, I will try to make more tests and see what happens. If you have any ideia I will be gratefully.
This is happening with me also. Here are some steps to reproduce the error I'm seeing:
bundle install
rails g scaffold User name:string email:string
) and migraterails generate avatars_for_rails:install user
and migrateacts_as_avatarable
to the user modelThe image is selectable, but I don't see the upload bar and it doesnt seem to work. In the database all data pertaining the logos is 'nil'. I've tried putting the form view inside the rails for or outside it, but neither works. With the difference that if I put it inside the form the submit button doesnt even work.
Tested on Firefox and Chromium latest versions. Hope that's enough to help you analyze this issue.
Hi @lfzawacki that's quite helpful. If you upload such an application to github I will take a look to it
There you go https://github.com/lfzawacki/avatars_for_rails_test
Ok, there was a problem with the javascript_tag, which is fixed in 1.1.3. Now it should work.
However, note that it works only for records (members or users) that are already created in the database. So the form in the new form will not work.
Please, reopen if you find further issues. Thank you for your feedback!
Sorry, but I have to tell you that it is still not working. I tried to use it for our own application (https://github.com/BluePanel/website) and also tried this one over here: https://github.com/lfzawacki/avatars_for_rails_test
None of them worked. In the test application still nothing happens and in our project I got the following error: Uncaught ReferenceError: $ is not defined edit:295 (anonymous function) edit:295
Line 295 to 297
$(function() {
AvatarForRails.edit();
});
Hi, got it working at https://github.com/daronco/avatars_for_rails_test
The problems were basically the dependencies:
current_user
and authenticate_user!
are from devise, so devise is clearly a dependency. (In the test app these methods also don't exist, since the model is called Member
and not User
. But since it can be configured in the initializer it worked.)crop!
. Tried with an older version of paperclip as well (trying to copy the dependencies from ging/vish@master), but it didn't work.Also had to explicitly make some attributes in the target model accessible, see this. I've seen this gem does something similar, but I guess in Rails 3.2 you still need the attr_accessible
calls.
I've added the gem strong_parameters before adding the attr_accessible
s and it didn't work. But I didn't really try to make it work, I guess it wasn't even being activated. Maybe if you set it up properly the attr_accessible
s are not necessary.
Changes: https://github.com/daronco/avatars_for_rails_test/compare/5be5fb61db9...40644768c5d59 (sorry, it's a bit extensive since I removed the entire gem from the repository...)
So what it seems to me is that the dependencies should be more clear. And if it is targeted for Rails 4.0 only, it should require Rails 4.0 only. At least it would be clear that it needs a few adaptations for Rails 3.2.
Is there any other example application for this gem?
Oh, and the call to image_tag(user.logo.url(:style))
points to an invalid image/url. When using the parameters :small
or :medium
it works fine tough.
Hi @daronco Thank you for the extensive feedback. Some comments:
attr_accessible
way of handling with protected params is now deprecated in Rails:style
thumbnail is not defined, only :small
and :medium
thumbnails are. These should also be clarified.We will be happy to merge a pull request that clarifies these issues, in the README or other documentation, and makes things easier for other users of the gem
@daronco Thank you for creating an working example application. :+1: So I could see how it looks like when it's working!
But in our application we still got this error: Uncaught ReferenceError: $ is not defined edit:295 (anonymous function) edit:295
Line 295 to 297
$(function() {
AvatarForRails.edit();
});
A created a new branch to push the current state: https://github.com/BluePanel/website/tree/avatar_%2329 Maybe someone of you got a clue what causes the problem! Thanks!
Hi @DeadlyAssassin it seems that jQuery is not loading in your application. I would check the browser's javascript console for errors
Hi @atd this was console output.
You are placing the javascript_tag at the end of the document:
https://github.com/BluePanel/website/blob/master/app/views/layouts/application.html.erb#L115
So jquery is defined after the avatars_for_rails snippet is executed
First of all thanks for your help @atd It's working now. I moved tthe javascript_tag to the top of the application layout and made some attributes accessible. See here: https://github.com/BluePanel/website/commit/a7584e0aaaa616886274dda5c08099fe3f8147ea
I think it would be better, if the javascript_tag could still be put in the bottom for perfomance reasons.
Hello
I'm trying to use this gem in one of my projects, and it appears not work properly. I followed the documentation but when I try to upload some image nothing happens.
I don't know if are missing some resources or if is needed to do some other configuration than described. Even trying in a new project the same problem happens.
Thank you,