Posts [ 6 ]

Topic: Carrierwave photo upload not working the way i want

I am building a photo uploader for my app. I have made a Photo model so that a user can have more photos "assigned" to it. I want to be able to see all the photos that a user has uploaded.

My problem is that when I upload a photo it is not registered anywhere in the database hence I am not able to view the photos. I am not sure where I am making a mistake, but I have also been having some problems with the fields_for block in the edit.html.erb. If I try to assign it to the form_for block by putting "f." in front of fields_for, the block will not show.

I have made a Gist with the code that I think is necessary for you guys to point me in the right direction or help me out.

Re: Carrierwave photo upload not working the way i want

Check the source code of your web page (Firefox with firebug plugin or Chrome will allow you to inspect the page) and check that the form is a multi-part form. If not then make the form multi-part See here for a good example of how to handle images with carrirer wave http://railscasts.com/episodes/253-carr le-uploads

What you want and what you need are too often not the same thing!When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.(Quote by me 15th July 2009)

Re: Carrierwave photo upload not working the way i want

I have followed the guide you're linking to very carefully while trying to create the photo uploader to start with. And I am using multipart.

But when I inspect the web page using Chrome the fields_for is nowhere to be found. Will you take a quick look at gist to see if I am doing something abviously wrong? I really do not understand this problem, and I have been struggling with it for two days now googling, and asking around. Following a lot of suggestions to problems similar to mine, but with no luck. Alternately give me an other maybe even better way to make it possible for a user to upload one picture at a time, but each picture should belong to the user and the user should be able to have more than one picture.

It looks like you are creating a form for an object that doesn't exist.Your controller action doesn;t seem to have anything to do with something called resource or resource_name

def update
@user.photos.build
end

@user presumably is the object that you are wanting to edit in the form? If so why aren't you doing form_for @user ?Also I have no idea what simple_form_for does, Never seen that before!Your form just looks ... well ,,, wrong! So much so that I don't really understand what it is you are trying to do

What you want and what you need are too often not the same thing!When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.(Quote by me 15th July 2009)

Re: Carrierwave photo upload not working the way i want

The simple_form_for is gem that works well with bootstrap. But just think of it as form_for. The rest of the form looks like that because it is auto created by Devise, since I am using Devise for authentication.

Re: Carrierwave photo upload not working the way i want

Ahh! Never used Devise.When you post the form back to the server does the photo appear in the params list? (Check your log file)If so, what happens to the data? Does it get saved? Again check your log file, you should be able to see what is happening.Post the log file entries here if you struggle to understand them.

What you want and what you need are too often not the same thing!When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.(Quote by me 15th July 2009)