No need to reinvent the wheel with file uploads, I've used PaperClip
to handle uploaded images and files with little trouble.

It's very easy to configure as to where the information gets stored -
in the database or out.


On Oct 31, 8: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
-~----------~----~----~----~------~----~------~--~---

Reply via email to