导轨触发控制器从击中mailto按钮? [英] rails trigger controller from hitting mailto button?

查看:154
本文介绍了导轨触发控制器从击中mailto按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在rails中,我希望用户点击mailto按钮,然后在控制器'home'中调用方法'mail',你怎么做?

这是我的代码,它似乎不工作...

  = mail_to boss.email:subject => boss.subj ,
:body =>hi boss,:action =>'home#mail'



有无论如何可以让mail_to打开一个新窗口到我的邮箱?

现在当我打到mail_to然后选择Gmail(firefox ubuntu),然后我直接去gmail ...
我希望它在新窗口中打开...无论如何在rails中执行它?

解决方案

请阅读 http://api.rubyonrails.org/classes/ActionView/Helpers /UrlHelper.html#method-i-mail_to 。它不提供

 :action => 'home#mail'

加入到mail_to方法中。这将简单地打开您的默认电子邮件客户端并填写主题,电子邮件地址和正文的值。如果你想在控制器中调用一个动作,你必须用link_to来完成。并考虑为此任务使用 ActionMailer ...


In rails, I want the user to hit the mailto button and then call the method 'mail' in controller 'home' , how you do that??

Here is my code, it seems doesnt work well...

= mail_to boss.email :subject=>boss.subj,    
:body=>"hi boss", :action=>'home#mail'

And is there anyway can make mail_to open a new windows to my mail box?
now when I hit mail_to and then select gmail (firefox ubuntu), then I go straight to gmail... I want it open in new windows... anyway to do it in rails?

解决方案

please read http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-mail_to exactly. It does not make sens to provide

:action => 'home#mail'

to the mail_to method. This will simply open your default email client and fill in the values for subject, email address and body. If you want to call a action in a controller, you have to do it with link_to. And think about using ActionMailer for this task ...

这篇关于导轨触发控制器从击中mailto按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆