small_avatar problems

Subscribe to small_avatar problems 13 post(s), 4 voice(s)

 
Avatar derrick 3 post(s)

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:


13:


14:
15: <% user.small_avatar%>
16:

17:


18:

RAILS_ROOT: script/../config/..
Application Trace | Framework Trace | Full Trace

 
Avatar EldonAlameda Administrator 196 post(s)

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

 
Avatar derrick 3 post(s)

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.

 
Avatar EldonAlameda Administrator 196 post(s)

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

 
Avatar derrick 3 post(s)

Yes, I can send it. Where should I send the project?

 
Avatar EldonAlameda Administrator 196 post(s)

alameda[dot]eldon[at]gmail[dot]com

 
Avatar Evan 3 post(s)

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:
23:


  • 26: <= image_tag user.avatar.public_filename(:comment) >
    27:


    28: <= link_to user.name, showprofile_path(:user => user) > posted on <= comment.created_at.to_s(:short) %>
    29:

    I was using the show_small_avatar method but ran into the same problem and tried this code as a workaround. What is worse is this code works once about every 5-10 minutes and then fails to 500 every time after.

    Any ideas?

    Edit note: sorry about the formatting, I am new here :)

  •  
    Avatar EldonAlameda Administrator 196 post(s)

    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

     
    Avatar Evan 3 post(s)

    Eldon,

    Definitely, I’ll send it over right away. Thanks so much for helping out!

    Evan

     
    Avatar dwmills 1 post

    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>
    Extracted source (around line #24):

    21:


  • 22:

    23:

    24:

    <= link_to(image_tag(user.small_avatarx), showuser_path(:user => user)) %>

    25: <= link_to user.name, showuser_path(:user => user) %> posted


    26:

    27:

  •  
    Avatar EldonAlameda Administrator 196 post(s)

    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
    config.cache_classes = false

    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.

     
    Avatar Evan 3 post(s)

    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

     
    Avatar EldonAlameda Administrator 196 post(s)

    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.