Hi, I''m having trouble with my correspond method (in my
email_controller). When I try passing "recipient" to my message method
(in my UserMailer model) I loose the information placed in the
"recipient", resulting in my Params_posted?(:message) to fail.
##############################################################
email_controller
##############################################################
def correspond
user = User.find(session[:user])
puts "\n\n\n correspond_dump1: user=#{session[:user].to_i}\n\n\n"
recipient = User.find_by_login(params[:login])
puts "\n\n\n correspond_dump2: recipient=#{recipient}\n\n\n"
@title = "Email #{recipient.login}"
if param_posted?(:message)
@message = Message.new(params[:message])
if @message.valid?
UserMailer.deliver_message(
:user => user,
:recipient => recipient,
:message => @message,
:user_url => presentation_for(user),
:reply_url => url_for(:action => "correspond",
:user => user.login)
)
flash[:notice] = "Email sent."
redirect_to :controller => "home", :action =>
"index"
end
end
end
##############################################################
UserMailer model
##############################################################
def message(mail)
subject mail[:message].subject
from ''CSCP
<do-not-reply-zYBJFIz3uvTLoDKTGw+V6w@public.gmane.org>''
puts "\n\n\n correspond_dump3:
UserMailer_recipient=#{mail[:recipient]}\n\n\n" ### inte user.login fel
user , id=0, :recipient=0, :login=0
recipients mail[:recipient]
body mail
end
##############################################################
Application_Controller
##############################################################
def param_posted?(sym)
request.post? and params[sym]
end
##############################################################
output in console
##############################################################
127.0.0.1 - - [24/Apr/2008:10:36:26 Võsteuropa, normaltid] "GET /email/
correspond?login=dagstensson%40hotmail.com HTTP/1.1" 200 520
http://localhost:3000/presentation?login=dagstensson%40hotmail.com -> /
email/correspond?login=dagstensson%40hotmail.com
correspond_dump1: user=60
correspond_dump2: recipient=#<User:0x460ba54>
127.0.0.1 - - [24/Apr/2008:10:37:09 Võsteuropa, normaltid] "GET /email/
correspond?login=dagstensson%40hotmail.com HTTP/1.1" 200 520
http://localhost:3000/presentation?login=dagstensson%40hotmail.com -> /
email/correspond?login=dagstensson%40hotmail.com
correspond_dump1: user=60
correspond_dump2: recipient
127.0.0.1 - - [24/Apr/2008:10:37:18 Võsteuropa, normaltid] "POST /
email/correspond HTTP/1.1" 500 8823
http://localhost:3000/email/correspond?login=dagstensson%40hotmail.com
-> /email/correspond
Now, what you''ve seen above is when I enter the form view and the
second part is when I hit the submit button to post it. It re-does the
first part of the code and tries to fetch the recipient but nothing is
found.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---