small_avatar problems
|
|
I’m having trouble with the small_avatar call from the photo/display.rhtml and post/display.rhtml. To ensure I was doing everything correctly, I downloaded the code from book and deployed it on the server. Unfortunately, the same problems still persist when I navigate to the pages above. What’s troubling is when I run the same code through ruby script/console it functions properly. The error is listed below. NoMethodError in Photos#show Showing app/views/photos/show.rhtml where line #15 raised: undefined method `small_avatar’ for #<user:0x3350694> Extracted source (around line #15): 12: 18: RAILS_ROOT: script/../config/.. |
|
|
Hi derrick, Sorry for the delay – I’ve been at RailsConf the last week and wasn’t checking my messages back here very often. could you confirm that your user model (/app/models/user.rb) contains the small_avatar method? Also could you tell me what type of server setup you’re running? It’s extra strange if it works in console on that server but not directly from the server – unless you’ve got an old process still running an older version of the code. Thanks Eldon |
|
|
The small_avatar method is there. I downloaded the code that was provide from railsproject. I had the server running locally on a mongrel server. In addition, I have hosted the same code on dreamhost using their server, yet the problems persist. |
|
|
Derrick, I’ve gone through the app but haven’t been able to reproduce your issue. (granted my current dev system currently has ImageMagick disabled for another project I’m on) but don’t think that would make a difference. Is there any way you could zip up your version of the app and send it to me so I could take a look through your code? Thanks |
|
|
Yes, I can send it. Where should I send the project? |
|
|
alameda[dot]eldon[at]gmail[dot]com |
|
|
Hey guys, I am having a similar problem to Derrick. Whenever I try to access a comment’s user’s avatar Rails returns this: “ActionView::TemplateError (undefined method `avatar’ for #<user:0x2b4d6165f8e0>) on line #26 of posts/show.html.erb: 26: <= image_tag user.avatar.public_filename(:comment) > 27: = link_to user.name, showprofile_path(:user => user) > posted on <= comment.created_at.to_s(:short) %> |
|
|
Evan, I don’t think that i ever got a response from Derrick with his project. Could you zip up the project as you currently have it and send it to my above email address. Since I can’t re-create the issue in any of my versions of the application it makes it hard to troubleshoot. I won’t be able to look at it until late tommorow at the earliest, but I’ll certainly do my best to see if I can figure out what’s causing the issue for you. Eldon |
|
|
Eldon, Definitely, I’ll send it over right away. Thanks so much for helping out! Evan |
|
|
Just wanted to add my “vote.” I am having the same issue. The small_avatar is “undefined.” Just like Evan, I have seen this work once correctly, and fail many times. I tried changing small_avatar to small_avatarx, but this did not change anything. Here is the error: NoMethodError in Posts#show Showing posts/show.rhtml where line #24 raised: undefined method `small_avatarx’ for #<user:0x22b9970> 21: 22: 23: 27: |
|
|
Finally got some free time to work on this tonight and haven’t quite identified the problem because it seems that for some reason the User class is being re-initialized after the first few requests (minus all of it’s associations, methods, etc). I’m still suspecting that it has something to do with one of the plugins – but can’t find anything yet However a quick work around for this – If you go into /config/environments – you have several environment files in there (development. production, test). These have a setting that says If you change that to true (and then restart your app) then it will only load the user model once and then keep using it. |
|
|
I found that setting config.cache_classes workes perfectly. This was the only thing I could get to work. While its a bummer that you have to have caching on, it works and works very reliably. Cheers, Evan |
|
|
It works but I’m sure there’s a better solution. I’m going to do deep dig into this and find out what the underlying issue is – it’s just that I’ve been swamped w/ a new job and finishing up the new book. So I should have the real answer within the next few weeks. |
13:
14:
15: <% user.small_avatar%>
16:
17: