# Select not working properly

**URL:** <https://www.ruby-forum.com/t/select-not-working-properly/126627>\
**Category:** Rails\
**Created:** [January 20, 2008, 5:58pm UTC](https://www.ruby-forum.com/t/select-not-working-properly/126627 "2008-01-20T17:58:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajatgarg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a183cd/32.png) [@rajatgarg](https://www.ruby-forum.com/u/rajatgarg)\
**Post date:** [January 20, 2008, 5:58pm UTC](https://www.ruby-forum.com/t/select-not-working-properly/126627/1 "2008-01-20T17:58:22Z")

</div>

Hi Guys,

I have created a form where a user can select from a drop down list of  
names. Based on the selection, a value is passed and appropriate email  
is looked up.

Then, I call actionmailer to deliver the email.

Problem is that it seems that (from log file) rhtml file is passing  
correct value to sendmail\_qualitylead action, however, toEmail in the  
action is either not getting set or not getting passed appropriately  
(sql command seems to be executed as shown in log file).

.rhtml file →   
\<%=form\_tag :controller=\>“xyz”, :action=\>“sendmail\_qualitylead”%\>

 ......

xyz\_controller →   
def sendmail\_qualitylead  
body=params[:lead]  
toEmail = Contact.find\_by\_sql([“select email from contacts where  
id=?”,body[“contactID”]])  
Notifier.deliver\_quality\_lead\_for\_flying\_club(body, toEmail)  
redirect\_to :action =\> “dosearch”  
end

Notifier.rb →   
def quality\_lead\_for\_flying\_club(body, toEmail)  
@subject = ‘Quality Lead’  
@body = body  
@recipients = toEmail  
@cc = body[“senderEmail”]  
@from = “supp [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)”  
@sent\_on = Time.now  
@headers = {}  
content\_type(“text/html”)  
end

I have spent almost a day stuck at this point ☹ and I will really  
appreciate any help.

Thanks

Rajat

| Name : | \<%=select(:lead, :contactID, @DropDown)%\> |

---

<div class="post-metadata">

**Author:** ![rajatgarg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a183cd/32.png) [@rajatgarg](https://www.ruby-forum.com/u/rajatgarg)\
**Post date:** [January 20, 2008, 8:18pm UTC](https://www.ruby-forum.com/t/select-not-working-properly/126627/2 "2008-01-20T20:18:15Z")

</div>

On 20 Jan 2008, at 16:57, Rajat G. wrote:

> correct value to sendmail\_qualitylead action, however, toEmail in the  
>   
>   
> …
> 
> xyz\_controller -\>  
> def sendmail\_qualitylead  
> body=params[:lead]  
> toEmail = Contact.find\_by\_sql([“select email from contacts where  
> id=?”,body[“contactID”]])  
> to\_Email will be an instance of Contact here, but it looks like you  
> are expecting it to be the email address itself.  
> Try passting toEmail.email to deliver\_quality\_lead\_for\_flying\_club

Fred
