A couple things: - Railsspace isn't the best tutorial to start with - the ideas are good, but trying to update a 1.2.3-era tutorial to present isn't the most helpful. It also re-implements a lot of things that have mostly been rolled into popular plugins (authentication for one; also this whole image upload bit).
- In general, always post as much backtrace from an error as you can. The final error is sometimes really just where the code fell down after wandering in the woods for a while. - Similarly, if you're troubleshooting a controller action, posting the log output for the action is handy as well; I've chased more than one bug in my own code that came down to a missing method= on a form, which shows up immediately in the log. - You are almost certainly missing something from the earlier chapters of Railsspace - I found the relevant discussion of routing (re: hub_url) in Chapter 9, Listing 9.39. Hope this helps! --Matt Jones On Oct 31, 7:47 am, RubyonRails_newbie <craigwest...@googlemail.com> wrote: > Hi Everyone! > > I'm trying to add the avatar upload functionality in Ruby on rails > following the railsspace book. > > Before I got the code and re-wrote it for my own needs, I wanted to > make sure everything worked anyway, so I added the code from the book > to the avatar controller etc.. > > When I attempted an upload, I got an error: NoMethodError in > AvatarController#upload > > So, when I look at the upload function, all seems OK to me. I'm > running rails 2.3.3 and have managed to get past every issue so far > without reverting back to an earlier version. > > def upload > @title = "Upload Your Avatar" > @user = User.find(session[:user_id]) > if param_posted?(:avatar) > image = params[:avatar][:image] > @avatar = Avatar.new(@user, image) > if @avatar.save > flash[:notice] = "Your avatar has been uploaded." > redirect_to hub_url > end > end > end > > Originally it had a problem because of this: > > def index > # redirect_to hub_url > end > > The error with this code in place reads: undefined local variable or > method `hub_url. This is displayed upon accessing url > :http://localhost:3000/avatar > > Can anyone help? > > I might look for another tutorial to upload avatars, but was hoping > there would be a simple solution.. > > Cheers! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---