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
--
Posted via http://www.ruby-forum.com/.
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
···
--
Posted via http://www.ruby-forum.com/.
Couldn't find Contact without an ID
···
2010/7/4 Kenneth <ken70r@gmail.com>
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
--
Posted via http://www.ruby-forum.com/\.
--
Thiago Fernandes Massa
11 83979414
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 <thiagown@gmail.com>
Couldn't find Contact without an ID
2010/7/4 Kenneth <ken70r@gmail.com>
> 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
> --
> Posted via http://www.ruby-forum.com/\.
>
>
--
Thiago Fernandes Massa
11 83979414
--
Thiago Fernandes Massa
11 83979414