redirect_to(user_contacts_path(@current_user)) error

A

Aashish Kiran

Hi, I am getting exception with
redirect_to(user_contacts_path(@current_user)),
but redirect_to works in other part of same method.

Here is part of code, redirect_to works in else statement, but not
working inside if statement
Error is an attachement uploaded.

Can anyone please help me.

----------------------------------------------------------------------------
if params[:commit] == "upload and import contact"
if params[:import_file].nil?
flash[:notice] = 'No file was attached.'
p user_contacts_path(@current_user)
p @current_user.contacts
redirect_to(user_contacts_path(@current_user))
else
parse_vcard_file(params[:import_file], params[:user_id])
flash[:notice] = 'Contact was successfully created from VCard
file.'
redirect_to(user_contacts_path(@current_user))
end


else

end
------------------------------------------------------------------------


thank you,
Ashish

Attachments:
http://www.ruby-forum.com/attachment/4837/contactserror.htm
 
K

Kenneth    

can you provide the error message???

also you can dry your code a little bit...

if params[:commit] == "upload and import contact"
if params[:import_file].nil?
flash[:notice] = 'No file was attached.'
p user_contacts_path(@current_user)
p @current_user.contacts
else
parse_vcard_file(params[:import_file], params[:user_id])
flash[:notice] = 'Contact was successfully created from VCard
file.'
end
redirect_to(user_contacts_path(@current_user))
else

end
 
T

Thiago Massa

[Note: parts of this message were removed to make it a legal post.]

Couldn't find Contact without an ID



2010/7/4 Kenneth said:
can you provide the error message???

also you can dry your code a little bit...

if params[:commit] == "upload and import contact"
if params[:import_file].nil?
flash[:notice] = 'No file was attached.'
p user_contacts_path(@current_user)
p @current_user.contacts
else
parse_vcard_file(params[:import_file], params[:user_id])
flash[:notice] = 'Contact was successfully created from VCard
file.'
end
redirect_to(user_contacts_path(@current_user))
else

end
 
T

Thiago Massa

[Note: parts of this message were removed to make it a legal post.]

by looking at ur code its probably because(i'm no rails expert or
whatsoever):

@current_user is something that do have an id(i think, i don't have the
whole code).

redirect_to(user_contacts_path(@current_user.id))

or

redirect_to(user_contacts_path:)id=>@current_user.id))

also, that's ruby ON RAILS, not ruby.

2010/7/4 Thiago Massa said:
Couldn't find Contact without an ID



2010/7/4 Kenneth said:
can you provide the error message???

also you can dry your code a little bit...

if params[:commit] == "upload and import contact"
if params[:import_file].nil?
flash[:notice] = 'No file was attached.'
p user_contacts_path(@current_user)
p @current_user.contacts
else
parse_vcard_file(params[:import_file], params[:user_id])
flash[:notice] = 'Contact was successfully created from VCard
file.'
end
redirect_to(user_contacts_path(@current_user))
else

end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,951
Messages
2,570,113
Members
46,698
Latest member
alexxx

Latest Threads

Top